Leetcode 1426 Solution

This article provides solution to leetcode question 1426 (find-n-unique-integers-sum-up-to-zero)

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)