2022-03-27 20:56:26 +08:00
< p > Given a < strong > non-empty< / strong > array of integers < code > nums< / code > , every element appears < em > twice< / em > except for one. Find that single one.< / p >
< p > You must implement a solution with a linear runtime complexity and use only constant extra space.< / p >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 20:56:26 +08:00
< pre > < strong > Input:< / strong > nums = [2,2,1]
< strong > Output:< / strong > 1
2023-12-09 18:42:21 +08:00
< / pre > < p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 20:56:26 +08:00
< pre > < strong > Input:< / strong > nums = [4,1,2,1,2]
< strong > Output:< / strong > 4
2023-12-09 18:42:21 +08:00
< / pre > < p > < strong class = "example" > Example 3:< / strong > < / p >
2022-03-27 20:56:26 +08:00
< pre > < strong > Input:< / strong > nums = [1]
< strong > Output:< / strong > 1
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = nums.length < = 3 * 10< sup > 4< / sup > < / code > < / li >
< li > < code > -3 * 10< sup > 4< / sup > < = nums[i] < = 3 * 10< sup > 4< / sup > < / code > < / li >
< li > Each element in the array appears twice except for one element which appears only once.< / li >
< / ul >