Using a provided ArrayReader API with compareSub(), find the index of the single largest integer.
You are given an array arr of integers where exactly one integer appears more than once. All other integers are unique. Using the ArrayReader API that provides compareSub(l1, r1, l2, r2) to compare the sum of subarrays, find the index of the integer that appears more than once.
Examples
Input:[1,2,3,3,4]
Output:2
Input:[2,2]
Output:0
Hints
Use binary search on the index, comparing left and right halves.
The repeated element creates an imbalance in sums.
Use divide and conquer to narrow down to the duplicate element.