From 255f27fe83afd115fea770ece8a3b46233e08021 Mon Sep 17 00:00:00 2001 From: Adithya Vinayak Date: Sun, 17 May 2026 12:21:15 -0400 Subject: [PATCH] working solution --- problem1.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 problem1.py diff --git a/problem1.py b/problem1.py new file mode 100644 index 00000000..b02901e8 --- /dev/null +++ b/problem1.py @@ -0,0 +1,19 @@ + +# https://leetcode.com/problems/two-sum/description/ + +class Solution(object): + def twoSum(self, nums, target): + """ + :type nums: List[int] + :type target: int + :rtype: List[int] + """ + dict_field={} + for i in range(len(nums)): + if nums[i] in dict_field: + dict_field[nums[i]].append(i) + return dict_field[nums[i]] + val = target-nums[i] + dict_field[val] = [i] + return [] + \ No newline at end of file