From a8dcdf8f53fa845d52974f9739a519dc80484e53 Mon Sep 17 00:00:00 2001 From: Gabriel Donnan <47415809+gabedonnan@users.noreply.github.com> Date: Thu, 12 Jan 2023 10:44:36 +0000 Subject: [PATCH] Create two-sum.py Not particularly elegant, but does the job --- two-sum.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 two-sum.py diff --git a/two-sum.py b/two-sum.py new file mode 100644 index 0000000..5fdc663 --- /dev/null +++ b/two-sum.py @@ -0,0 +1,13 @@ +class Solution(object): + def twoSum(self, nums, target): + """ + :type nums: List[int] + :type target: int + :rtype: List[int] + """ + temp = [] + for i,num in enumerate(nums): + for j, item in enumerate(temp): + if item + num == target: + return [i,j] + temp.append(num)