aboutsummaryrefslogtreecommitdiff
path: root/find_n_unique_int_sum_0.py
diff options
context:
space:
mode:
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))