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

Method main

java/Chapter 9/Question9_3/Question.java:50–66  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

48 }
49
50 public static void main(String[] args) {
51 for (int i = 0; i < 1000; i++) {
52 int size = AssortedMethods.randomIntInRange(5, 20);
53 int[] array = getDistinctSortedArray(size);
54 int v2 = magicFast(array);
55 if (v2 == -1 && magicSlow(array) != -1) {
56 int v1 = magicSlow(array);
57 System.out.println("Incorrect value: index = -1, actual = " + v1 + " " + i);
58 System.out.println(AssortedMethods.arrayToString(array));
59 break;
60 } else if (v2 > -1 && array[v2] != v2) {
61 System.out.println("Incorrect values: index= " + v2 + ", value " + array[v2]);
62 System.out.println(AssortedMethods.arrayToString(array));
63 break;
64 }
65 }
66 }
67
68}

Callers

nothing calls this directly

Calls 5

randomIntInRangeMethod · 0.95
magicFastMethod · 0.95
magicSlowMethod · 0.95
arrayToStringMethod · 0.95

Tested by

no test coverage detected