Loading...
You are given a non-empty integer array nums in which every value appears exactly twice, except for one value that appears exactly once.
nums
Return the value that appears once.
You must write an algorithm that runs in O(n)O(n)O(n) time and uses only O(1)O(1)O(1) extra space.
Input: nums = [2, 2, 1] Output: 1 Explanation: The value 2 appears twice; 1 is the value that appears once.
Input: nums = [4, 1, 2, 1, 2] Output: 4
Input: nums = [1] Output: 1
nums.length
nums[i]
Click "Run" to test with sample cases or "Submit" to run all tests.