diff --git a/leetcode/1.py b/leetcode/1.py new file mode 100644 index 0000000..d96e79e --- /dev/null +++ b/leetcode/1.py @@ -0,0 +1,24 @@ +# Give a list and a number. +# Return a list of indices of two numbers + + +class Solution: + def twoSum(self, nums: list[int], target: int) -> list[int]: + answer = [] + for i in range(len(nums) // 2 + 1): + if target - nums[i] == nums[i]: + continue + if target - nums[i] in nums: + answer.append(i) + answer.append(nums.index(target - nums[i])) + return answer + + return answer + + +""" +test = [1, 2, 3] +TARGET_NUMBER = 3 +a = Solution().twoSum(test, TARGET_NUMBER) +print(a) +"""