【Amazon面经】Find N Unique Integers Sum up to Zero Amazon OA 开发岗 数据岗 其他岗位

喵贵妃 2020-6-17 1274


Given an integer n, return any array containing n unique integers such that they add up to 0.

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]

最新回复 (0)
返回