aboutsummaryrefslogtreecommitdiff
path: root/find_n_unique_int_sum_0.py
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-09-06 20:58:35 -0600
committerJack Sangdahl <[email protected]>2025-09-06 20:58:35 -0600
commite70ec56060a9085a0847d3014c5aecdb0298830a (patch)
tree5a28e80a73fa2b066de4d66c38867f269553ece8 /find_n_unique_int_sum_0.py
parent8eca342b99ab30a60285fc842f0229ab60ba2bcc (diff)
downloadleetcode-e70ec56060a9085a0847d3014c5aecdb0298830a.tar.gz
leetcode-e70ec56060a9085a0847d3014c5aecdb0298830a.zip
1304. find n unique integers sum up to zero
Diffstat (limited to 'find_n_unique_int_sum_0.py')
-rw-r--r--find_n_unique_int_sum_0.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/find_n_unique_int_sum_0.py b/find_n_unique_int_sum_0.py
new file mode 100644
index 0000000..a4936ff
--- /dev/null
+++ b/find_n_unique_int_sum_0.py
@@ -0,0 +1,22 @@
+# 1304. Find N Unique Integers Sum up to Zero
+
+"""
+given an integer 'n', return any array containing 'n' unique integers such
+that they add up to 0.
+"""
+
+
+class Solution(object):
+ def sumZero(self, n):
+ """
+ :type n: int
+ :rtype: List[int]
+ """
+ return range(1 - n, n, 2)
+
+
+if __name__ == "__main__":
+ obj = Solution()
+ print(obj.sumZero(5))
+ print(obj.sumZero(3))
+ print(obj.sumZero(1))