645. Set Mismatch Easy

@problem@discussion
#Array#Hash Table#Bit Manipulation#Sorting



1/**
2 * [645] Set Mismatch
3 *
4 * You have a set of integers s, which originally contains all the numbers from 1 to n. Unfortunately, due to some error, one of the numbers in s got duplicated to another number in the set, which results in repetition of one number and loss of another number.
5 * You are given an integer array nums representing the data status of this set after the error.
6 * Find the number that occurs twice and the number that is missing and return them in the form of an array.
7 *  
8 * Example 1:
9 * Input: nums = [1,2,2,4]
10 * Output: [2,3]
11 * Example 2:
12 * Input: nums = [1,1]
13 * Output: [1,2]
14 *  
15 * Constraints:
16 * 
17 * 	2 <= nums.length <= 10^4
18 * 	1 <= nums[i] <= 10^4
19 * 
20 */
21pub struct Solution {}
22
23// problem: https://leetcode.com/problems/set-mismatch/
24// discuss: https://leetcode.com/problems/set-mismatch/discuss/?currentPage=1&orderBy=most_votes&query=
25
26// submission codes start here
27
28impl Solution {
29    pub fn find_error_nums(nums: Vec<i32>) -> Vec<i32> {
30        vec![]
31    }
32}
33
34// submission codes end
35
36#[cfg(test)]
37mod tests {
38    use super::*;
39
40    #[test]
41    fn test_645() {
42    }
43}
44


Back
© 2025 bowen.ge All Rights Reserved.