Find N Unique Integers That Sum up to Zero

52.7% Acceptance

In this coding lab, you'll be implementing a function that returns an array of unique integers with a sum of 0. The function takes an integer n as input, and the resulting array should contain n unique integers that add up to zero.

To better understand the problem, consider the following examples:

Example 1:

Input: n = 5 Output: [-7,-1,1,3,4] Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].

Example 2:

Input: n = 3 Output: [-1,0,1]

Example 3:

Input: n = 1 Output: [0]


  • 1 <= n <= 1000

You'll be solving this lab by creating multiple challenges, and the evaluation script will check and verify your solution for each challenge. Remember to use ESM import/export everywhere and export any function or variable you want to use for testing in the evaluation script.

Once you've created the challenges and the evaluation script, you can proceed to test your lab using the provided "Setting up test environment script". Install any new packages if required and add them to the dependencies or devDependencies in the package.json file in your solution. Use the .cdmrc file provided without any changes.

Happy coding!