Java Binary Search O(log(n)) Shorter Than Others
My solution using binary search. lo and hi are not regular index, but the pair index here. Basically you want to find the first even-index number not followed b
My solution using binary search. lo and hi are not regular index, but the pair index here. Basically you want to find the first even-index number not followed by the same number.\n```\npublic class Solution {\n    public int singleNonDuplicate(int[] nums) {\n        // binary search\n        int n=nums.length, lo=0, hi=n/2;\n        while (lo < hi) {\n            int m = (lo + hi) / 2;\n            if (nums[2*m]!=nums[2*m+1]) hi = m;\n            else lo = m+1;\n        }\n        return nums[2*lo];\n    }\n}\n```
[]