961. N-Repeated Element in Size 2N Array Easy
1/**
2 * [961] N-Repeated Element in Size 2N Array
3 *
4 * You are given an integer array nums with the following properties:
5 *
6 * nums.length == 2 * n.
7 * nums contains n + 1 unique elements.
8 * Exactly one element of nums is repeated n times.
9 *
10 * Return the element that is repeated n times.
11 *
12 * Example 1:
13 * Input: nums = [1,2,3,3]
14 * Output: 3
15 * Example 2:
16 * Input: nums = [2,1,2,5,3,2]
17 * Output: 2
18 * Example 3:
19 * Input: nums = [5,1,5,2,5,3,5,4]
20 * Output: 5
21 *
22 * Constraints:
23 *
24 * 2 <= n <= 5000
25 * nums.length == 2 * n
26 * 0 <= nums[i] <= 10^4
27 * nums contains n + 1 unique elements and one of them is repeated exactly n times.
28 *
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/n-repeated-element-in-size-2n-array/
33// discuss: https://leetcode.com/problems/n-repeated-element-in-size-2n-array/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38 pub fn repeated_n_times(nums: Vec<i32>) -> i32 {
39 0
40 }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_961() {
51 }
52}
53
Back
© 2025 bowen.ge All Rights Reserved.