Java - Binary Search O(log N) time and O(1) memory
\nclass Solution {\n    public int singleNonDuplicate(int[] nums) {\n        int N = nums.length;\n        if(N == 1)\n            return nums[0];\n        \n  
```\nclass Solution {\n    public int singleNonDuplicate(int[] nums) {\n        int N = nums.length;\n        if(N == 1)\n            return nums[0];\n        \n        int left = 0;\n        int right = N - 1;\n        int mid;\n        \n        while(left < right){\n            mid = left + ((right  - left) >> 1);\n            if(nums[mid] == nums[mid + 1]){\n                // from index mid to (N - 1) - if even then check left interval\n                if(((N - mid) & 1) == 0)\n                    right = mid - 1;\n                else\n                    left = mid + 2;\n            }else if(nums[mid] == nums[mid - 1]){\n                // from index (mid - 1) to (N - 1) - if even then check left interval\n                if(((N - mid + 1) & 1) == 0)\n                    right = mid - 2;\n                else\n                    left = mid + 1;\n            }else\n                return nums[mid];\n        }\n        \n        return nums[left];\n    }\n}\n```
[]