---
# System prepended metadata

title: 1533. Find the Index of the Large Integer
tags: [Leetcode, Binary Search, Medium]

---

# 1533. Find the Index of the Large Integer
###### tags: `Leetcode` `Medium` `Binary Search`
Link: https://leetcode.com/problems/find-the-index-of-the-large-integer/
## 思路 $O(logN)$ $O(1)$
因为比的是两个subarray的sum
所以一定要让两个subarray的size一样才比的出来
## Code
```java=
class Solution {
    public int getIndex(ArrayReader reader) {
        int start = 0;
        int end = reader.length()-1;
        while(start<end){
            int mid = start+(end-start)/2;
            int result;
            if((end-start+1)%2==0) result = reader.compareSub(start, mid, mid+1, end);
            else result = reader.compareSub(start, mid, mid, end);
            if(result == -1){
                start = mid+1;
            }
            else end = mid;
        }
        return start;
    }
}
```