Image Transcription:
[Screenshot of a function which returns the length of an array]
public static int arrayLength(int[] arr) {
int min = 0;
int max = Integer.MAX_VALUE;
while (min + 1 < max) {
int mid = (min + max) / 2;
try {
int elem = arr[mid];
max = mid - 1;
} catch (ArrayIndexOutOfBoundsException e) {
min = mid + 1;
}
}
return min;
}
^^I'm a human volunteer content transcriber for Reddit! If you'd like more information on what we do and why we do it, click here!