@@ -0,0 +1,863 @@
+package Chapter1.Section2;%0A%0Aimport edu.princeton.cs.algs4.*;%0Aimport java.util.Arrays;%0A%0Apublic class Exercise09%0A%7B%0A    public static int rank(int key, int%5B%5D a, Counter counter)%0A    %7B%09// Array must be sorted.%0A%09int lo = 0;%0A%09int hi = a.length - 1;%0A%09while (lo %3C= hi)%0A%09%7B   // Key is in a%5Blo..hi%5D or not present.%0A%09    counter.increment();%0A%09    int mid = lo + (hi - lo) / 2;%0A%09    if%09    (key %3C a%5Bmid%5D) hi = mid - 1;%0A%09    else if (key %3E a%5Bmid%5D) lo = mid + 1;%0A%09    else%09%09    return mid;%0A%09%7D%0A%09return -1;%0A    %7D%0A%0A    public static void main(String%5B%5D args)%0A    %7B%0A%09int%5B%5D whitelist = In.readInts(args%5B0%5D);%0A%0A%09Arrays.sort(whitelist);%0A%09Counter counter = new Counter(%22keys%22);%0A%0A%09while (!StdIn.isEmpty())%0A%09%7B   // Read key, print if not in whitelist.%0A%09    int key = StdIn.readInt();%0A%09    if (rank(key, whitelist, counter) %3C 0)%0A%09%09StdOut.println(key);%0A%09%7D%0A%0A%09StdOut.println(counter);%0A    %7D%0A%7D%0A

Solved 1.2.9