1304. Find N Unique Integers Sum up to Zero Easy

@problem@discussion
#Array#Math



1/**
2 * [1304] Find N Unique Integers Sum up to Zero
3 *
4 * Given an integer n, return any array containing n unique integers such that they add up to 0.
5 *  
6 * Example 1:
7 * 
8 * Input: n = 5
9 * Output: [-7,-1,1,3,4]
10 * Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].
11 * 
12 * Example 2:
13 * 
14 * Input: n = 3
15 * Output: [-1,0,1]
16 * 
17 * Example 3:
18 * 
19 * Input: n = 1
20 * Output: [0]
21 * 
22 *  
23 * Constraints:
24 * 
25 * 	1 <= n <= 1000
26 * 
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero/
31// discuss: https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36    pub fn sum_zero(n: i32) -> Vec<i32> {
37        vec![]
38    }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45    use super::*;
46
47    #[test]
48    fn test_1304() {
49    }
50}
51


Back
© 2025 bowen.ge All Rights Reserved.