From 63d05a377a1d8af83017b75ff28c507c420b668c Mon Sep 17 00:00:00 2001 From: Tiger Date: Mon, 5 May 2025 12:00:38 -0400 Subject: [PATCH 1/3] added my solution for problem 1 --- Python/TwoSum.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Python/TwoSum.py diff --git a/Python/TwoSum.py b/Python/TwoSum.py new file mode 100644 index 00000000..4a3c0a72 --- /dev/null +++ b/Python/TwoSum.py @@ -0,0 +1,7 @@ +class Solution: + def twoSum(self, nums: List[int], target: int) -> List[int]: + for i in range(len(nums)): + for j in range(i+1, len(nums)): + if nums[i] + nums[j] == target: + ans = [i, j] + return ans \ No newline at end of file From 277ee6c0baad1bc7a369b7d92a58d9aa86acdda5 Mon Sep 17 00:00:00 2001 From: Tiger Date: Tue, 6 May 2025 11:59:51 -0400 Subject: [PATCH 2/3] added my solution to 26 --- Python/26_Remove_Duplicates_from_Sorted_Array.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Python/26_Remove_Duplicates_from_Sorted_Array.py diff --git a/Python/26_Remove_Duplicates_from_Sorted_Array.py b/Python/26_Remove_Duplicates_from_Sorted_Array.py new file mode 100644 index 00000000..a62f3a97 --- /dev/null +++ b/Python/26_Remove_Duplicates_from_Sorted_Array.py @@ -0,0 +1,8 @@ +class Solution: + def removeDuplicates(self, nums: List[int]) -> int: + i = 1 + while i Date: Wed, 7 May 2025 16:10:50 -0400 Subject: [PATCH 3/3] added my solution for 20 --- Python/20_Valid_parentheses.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Python/20_Valid_parentheses.py diff --git a/Python/20_Valid_parentheses.py b/Python/20_Valid_parentheses.py new file mode 100644 index 00000000..6114ae70 --- /dev/null +++ b/Python/20_Valid_parentheses.py @@ -0,0 +1,21 @@ +class Solution: + def isValid(self, s: str) -> bool: + stack = [] + for i in range(len(s)): + if s[i] == "(" or s[i] == "[" or s[i] == "{": #check if an open bracket, push to stack + stack.append(s[i]) + if s[i] == ")" or s[i] == "]" or s[i] == "}": #check if closing bracket, pop from stack and compare + if len(stack) == 0: + return False + prev = stack.pop() + if prev == "(" and s[i] != ")": + return False + if prev == "[" and s[i] != "]": + return False + if prev == "{" and s[i] != "}": + return False + + if len(stack) == 0: + return True + else: + return False \ No newline at end of file