Java Code by using binary search O(log(n))
public int singleNonDuplicate(int[] nums) {\n        int low = 0;\n        int high = nums.length-1;\n        \n        while(low < high) {\n            int mid
public int singleNonDuplicate(int[] nums) {\n        int low = 0;\n        int high = nums.length-1;\n        \n        while(low < high) {\n            int mid = low + (high - low)/2;\n            if(nums[mid] != nums[mid+1] && nums[mid] != nums[mid-1])\n                return nums[mid];\n            else if(nums[mid] == nums[mid+1] && mid % 2 == 0)\n                low = mid+1;\n            else if(nums[mid] == nums[mid-1] && mid % 2 == 1)\n                low = mid+1;\n            else\n                high = mid-1;\n        }\n        return nums[low];\n    }
[]