1 class Solution: 2 def sumZero(self, n: int) -> List[int]: 3 res = [] 4 k = n // 2 5 i = 1 6 for j in range(k): 7 res.append(i) 8 res.append(i * (-1)) 9 i += 1 10 if n % 2 == 1: 11 res.append(0) 12 return res
1 class Solution: 2 def sumZero(self, n: int) -> List[int]: 3 res = [] 4 k = n // 2 5 i = 1 6 for j in range(k): 7 res.append(i) 8 res.append(i * (-1)) 9 i += 1 10 if n % 2 == 1: 11 res.append(0) 12 return res