Easy in C++😎  ||Binary Search|| (21st Feb 2023)
A good solution here would work even if the elements were not sorted, but just kept in pairs  and that is because the searching criterium we will use is not rel
*A good solution here would work even if the elements were not sorted, but just kept in pairs  and that is because the searching criterium we will use is not related to their own ordering, but to the fact that numbers to the left of the unique element will have the format nums[k] == nums[k + 1] with k being an even index and the ones to the right of it will have the same with k being an odd index.*\n\n*First of all, we will declare a couple of support variables:*\n\n*lmt as the name implies will be the upper limit of our search, set to be the very last index (nums.size() - 1);\nmid, the middle element of our binary search.\nWe will then proceeed to loop with a few more variables:*\n\n*l and r are the two pointers to the left and right interval we will be binary searching - initially set to be 0 and lmt, respectively;\nprev and nxt will be the values we will consider for the elements around the one pointed by mid.\nIn our loop, running as long as l <= r, we will then:*\n\n*compute mid, as the average between l and r;\ncompute prev so that is equal to the previous element if mid is not on the first element or nums[mid] - 1 otherwise;\ncompute nxt so that is equal to the previous element if mid is not on the first element or nums[mid] + 1 otherwise - and, yes: I found delight in the elegance of having an expression moving the - 1 / + 1 part inside or outside the square brackets;\ntime to go for the actual binary search and we will deal with 3 cases:\nif nums[mid] is different from both prev and nxt, we know we have a match, so we can just return nums[mid];\nif nums[mid] is different from the previous element with an odd value of mid or from the next one with an even value of mid, it means we were looking too much to the right, so we will lower r to be mid - 1 in the next iteration (we might also have written the condition here as nums[mid] != nums[mid + (mid & 1 ? -1 : 1)], which was my first version, before storing prev and nxt for convenience);\notherwise, it means we were looking too much to the left, so we will adjust l to be mid + 1.\nI am not sure we will ever hit exit the loop and execute what is next, but just to make the compiler happy about the signature of our function, we will then just in case return nums[mid] and be done with it :)*\n\n**The code:**\n\n```\nclass Solution {\npublic:\n    int singleNonDuplicate(vector<int>& nums) {\n        // support variables\n        int lmt = nums.size() - 1, mid;\n        // binary search\n        for (int l = 0, r = lmt, prev, nxt; l <= r;) {\n            // updating loop variables\n            mid = (l + r) >> 1;\n            prev = mid ? nums[mid - 1] : nums[mid] - 1;\n            nxt = mid != lmt ? nums[mid + 1] : nums[mid] + 1;\n            // checking the element pointed by mid:\n            // match\n            if (nums[mid] != prev && nums[mid] != nxt) return nums[mid];\n            // too high\n            else if (nums[mid] != (mid & 1 ? prev : nxt)) r = mid - 1;\n            // too low\n            else l = mid + 1;\n        }\n        return nums[mid];\n    }\n};\n```\n\n![image](https://assets.leetcode.com/users/images/f30cc85c-5d8c-435c-a8f9-c0ccb4548997_1676951964.5447822.jpeg)\n\n
['C', 'Binary Tree', 'C++']