Leetcode 1426 Solution
This article provides solution to leetcode question 1426 (find-n-unique-integers-sum-up-to-zero)
Access this page by simply typing in "lcs 1426" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero
Solution
class Solution:
def sumZero(self, n: int) -> List[int]:
q = collections.deque()
if n % 2 == 1:
q.append(0)
n -= 1
v = 1
while n:
q.appendleft(-v)
q.append(v)
v += 1
n -= 2
return list(q)