MCPcopy Index your code
hub / github.com/careercup/ctci / magicFast

Method magicFast

java/Chapter 9/Question9_3/Question.java:18–30  ·  view source on GitHub ↗
(int[] array, int start, int end)

Source from the content-addressed store, hash-verified

16 }
17
18 public static int magicFast(int[] array, int start, int end) {
19 if (end < start || start < 0 || end >= array.length) {
20 return -1;
21 }
22 int mid = (start + end) / 2;
23 if (array[mid] == mid) {
24 return mid;
25 } else if (array[mid] > mid){
26 return magicFast(array, start, mid - 1);
27 } else {
28 return magicFast(array, mid + 1, end);
29 }
30 }
31
32 public static int magicFast(int[] array) {
33 return magicFast(array, 0, array.length - 1);

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected