✅  Multiple Javascript Solutions || Brute Force O(n) O(1) || Binary Search O(logn) O(1) || XOR
Feel free to ask Q\'s...\n#happytohelpu\n\nDo upvote if you find this solution useful. Happy Coding!\n\nSolution 1 : Brute Force (with XOR)\nTime Complexity : O
**Feel free to ask Q\'s...**\n*#happytohelpu*\n\n***Do upvote if you find this solution useful. Happy Coding!***\n\n**Solution 1 : Brute Force (with XOR)**\nTime Complexity : O(n)\nSpace Complexity : O(1)\n\n```\n\nconst singleNonDuplicate = nums => nums.reduce((a, b) => a ^ b); // XOR to get the single value\n\n```\n\n\n**Solution 2 : Brute Force**\nTime Complexity : O(n)\nSpace Complexity : O(1) \n\n```\n\nconst singleNonDuplicate = nums => {\n    //Compare consecutive numbers and increment by 2 in each iteration\n    for (let i = 0; i < nums.length - 1; i += 2) {\n        if (nums[i] != nums[i + 1]) {\n            return nums[i];\n        }\n    }\n    return nums[nums.length - 1]; // The last element is the only single element.\n}\n\n```\n\n**Solution 3 : Binary Search**\nTime Complexity : O(log(n))\nSpace Complexity : O(1) \n\n```\n\nconst singleNonDuplicate = (nums, left = 0, right = nums.length - 1) => {\n\n    while (left < right) {\n        let mid = left + (right - left) / 2;\n        if (nums[mid] == nums[mid + 1]) mid = mid - 1;\n        if ((mid - left + 1) % 2 != 0) right = mid;\n        else left = mid + 1;\n    }\n    return nums[left];\n};\n\n```\n\n\n
['Binary Search', 'Bit Manipulation', 'Binary Tree', 'Iterator', 'JavaScript']