260. Single Number III Medium

@problem@discussion
#Array#Bit Manipulation



1/**
2 * [260] Single Number III
3 *
4 * Given an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in any order.
5 * You must write an algorithm that runs in linear runtime complexity and uses only constant extra space.
6 *  
7 * Example 1:
8 * 
9 * Input: nums = [1,2,1,3,2,5]
10 * Output: [3,5]
11 * Explanation:  [5, 3] is also a valid answer.
12 * 
13 * Example 2:
14 * 
15 * Input: nums = [-1,0]
16 * Output: [-1,0]
17 * 
18 * Example 3:
19 * 
20 * Input: nums = [0,1]
21 * Output: [1,0]
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	2 <= nums.length <= 3 * 10^4
27 * 	-2^31 <= nums[i] <= 2^31 - 1
28 * 	Each integer in nums will appear twice, only two integers will appear once.
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/single-number-iii/
34// discuss: https://leetcode.com/problems/single-number-iii/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn single_number(nums: Vec<i32>) -> Vec<i32> {
40        vec![]
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_260() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.