From 598ae277e41513a021ad3663a0d85dec618c93fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=98=B8?= <101695482+chordpli@users.noreply.github.com> Date: Sat, 26 Jul 2025 11:39:25 +0900 Subject: [PATCH 1/6] feat: 1week MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: 1주차 1,2 문제 --- contains-duplicate/chordpli.py | 12 ++++++++++++ two-sum/chordpli.py | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 contains-duplicate/chordpli.py create mode 100644 two-sum/chordpli.py diff --git a/contains-duplicate/chordpli.py b/contains-duplicate/chordpli.py new file mode 100644 index 000000000..b61243832 --- /dev/null +++ b/contains-duplicate/chordpli.py @@ -0,0 +1,12 @@ +from typing import List + +class Solution: + def containsDuplicate(self, nums: List[int]) -> bool: + dic = {} + + for num in nums: + if dic.get(num): + return True + dic[num] = 1 + + return False diff --git a/two-sum/chordpli.py b/two-sum/chordpli.py new file mode 100644 index 000000000..2e269a040 --- /dev/null +++ b/two-sum/chordpli.py @@ -0,0 +1,11 @@ +from typing import List + +class Solution: + def twoSum(self, nums: List[int], target: int) -> List[int]: + map = {} + for i, num in enumerate(nums): + complement = target - num + if complement in map: + return [map[complement], i] + + map[num] = i From 5a8364bda00efb8c6d77079c13037be5780e4354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=98=B8?= <101695482+chordpli@users.noreply.github.com> Date: Sun, 3 Aug 2025 00:36:19 +0900 Subject: [PATCH 2/6] feat: 2week (#2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 242 문제 * feat: 70 문제 * feat: leetcode / 15 / success / 투포인터 --- 3sum/chordpli.py | 31 +++++++++++++++++++++++++++++++ climbing-stairs/chordpli.py | 13 +++++++++++++ valid-anagram/chordpli.py | 19 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 3sum/chordpli.py create mode 100644 climbing-stairs/chordpli.py create mode 100644 valid-anagram/chordpli.py diff --git a/3sum/chordpli.py b/3sum/chordpli.py new file mode 100644 index 000000000..498b7d232 --- /dev/null +++ b/3sum/chordpli.py @@ -0,0 +1,31 @@ +from typing import List + + +class Solution: + def threeSum(self, nums: List[int]) -> List[List[int]]: + answer = [] + nums.sort() + nums_len = len(nums) + + for i in range(nums_len - 2): + if i > 0 and nums[i] == nums[i - 1]: + continue + left, right = i + 1, nums_len - 1 + + while left < right: + current_sum = nums[i] + nums[left] + nums[right] + if current_sum < 0: + left += 1 + elif current_sum > 0: + right -= 1 + + else: + answer.append([nums[i], nums[left], nums[right]]) + while left < right and nums[left] == nums[left + 1]: + left += 1 + while left < right and nums[right] == nums[right - 1]: + right -= 1 + left += 1 + right -= 1 + + return answer diff --git a/climbing-stairs/chordpli.py b/climbing-stairs/chordpli.py new file mode 100644 index 000000000..7169e9358 --- /dev/null +++ b/climbing-stairs/chordpli.py @@ -0,0 +1,13 @@ +class Solution: + def climbStairs(self, n: int) -> int: + if n <= 2: + return n + + dp = [0] * (n + 1) + dp[1] = 1 + dp[2] = 2 + + for i in range(3, n + 1): + dp[i] = dp[i - 1] + dp[i - 2] + + return dp[n] diff --git a/valid-anagram/chordpli.py b/valid-anagram/chordpli.py new file mode 100644 index 000000000..5aa040151 --- /dev/null +++ b/valid-anagram/chordpli.py @@ -0,0 +1,19 @@ +class Solution: + # dictionary 사용 11ms + def isAnagram(self, s: str, t: str) -> bool: + check = {} + for char in s: + if char not in check: + check[char] = 0 + check[char] += 1 + for char in t: + if char not in check: + return False + check[char] -= 1 + if check[char] == 0: + del check[char] + return not check + + # 정렬 사용 15 - 20ms + # def isAnagram(self, s: str, t: str) -> bool: + # return sorted(s) == sorted(t) From ee9872eccb7560d505afbba2542c1202a9f17f20 Mon Sep 17 00:00:00 2001 From: pli Date: Sat, 9 Aug 2025 23:21:31 +0900 Subject: [PATCH 3/6] 3week --- combination-sum/chordpli.py | 29 +++++++++++++++++++++++++++++ number-of-1-bits/chordpli.py | 3 +++ valid-palindrome/chordpli.py | 13 +++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 combination-sum/chordpli.py create mode 100644 number-of-1-bits/chordpli.py create mode 100644 valid-palindrome/chordpli.py diff --git a/combination-sum/chordpli.py b/combination-sum/chordpli.py new file mode 100644 index 000000000..d21973bcf --- /dev/null +++ b/combination-sum/chordpli.py @@ -0,0 +1,29 @@ +from typing import List + + +class Solution: + def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: + result = [] + candidates.sort() + self.__backtrack__(candidates, 0, target, result, []) + return result + + def __backtrack__(self, candidates: List[int], current_idx: int, target: int, result: List[List[int]], + current_arr: List[int]): + if current_idx >= len(candidates): + return + + add_value = sum(current_arr) + candidates[current_idx] + + if add_value == target: + current_arr.append(candidates[current_idx]) + result.append(current_arr.copy()) + current_arr.pop() + + if add_value > target: + return self.__backtrack__(candidates, current_idx + 1, target, result, current_arr) + + current_arr.append(candidates[current_idx]) + self.__backtrack__(candidates, current_idx, target, result, current_arr) + current_arr.pop() + self.__backtrack__(candidates, current_idx + 1, target, result, current_arr) \ No newline at end of file diff --git a/number-of-1-bits/chordpli.py b/number-of-1-bits/chordpli.py new file mode 100644 index 000000000..fc4d68eec --- /dev/null +++ b/number-of-1-bits/chordpli.py @@ -0,0 +1,3 @@ +class Solution: + def hammingWeight(self, n: int) -> int: + return bin(n).count('1') \ No newline at end of file diff --git a/valid-palindrome/chordpli.py b/valid-palindrome/chordpli.py new file mode 100644 index 000000000..0f46eb701 --- /dev/null +++ b/valid-palindrome/chordpli.py @@ -0,0 +1,13 @@ +import re + + +class Solution: + def isPalindrome(self, s: str) -> bool: + lower_s = s.lower() + lower_eng_str = re.sub(r"[^a-z0-9]", "", lower_s) + reverse_str = lower_eng_str[::-1] + + if lower_eng_str == reverse_str: + return True + + return False \ No newline at end of file From 66e51b0ab58075d63edbf04c5af109f17e324e4f Mon Sep 17 00:00:00 2001 From: pli Date: Sun, 10 Aug 2025 11:23:07 +0900 Subject: [PATCH 4/6] style: lint --- combination-sum/chordpli.py | 2 +- number-of-1-bits/chordpli.py | 2 +- valid-palindrome/chordpli.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/combination-sum/chordpli.py b/combination-sum/chordpli.py index d21973bcf..41ed285c8 100644 --- a/combination-sum/chordpli.py +++ b/combination-sum/chordpli.py @@ -26,4 +26,4 @@ def __backtrack__(self, candidates: List[int], current_idx: int, target: int, re current_arr.append(candidates[current_idx]) self.__backtrack__(candidates, current_idx, target, result, current_arr) current_arr.pop() - self.__backtrack__(candidates, current_idx + 1, target, result, current_arr) \ No newline at end of file + self.__backtrack__(candidates, current_idx + 1, target, result, current_arr) diff --git a/number-of-1-bits/chordpli.py b/number-of-1-bits/chordpli.py index fc4d68eec..dc214bef8 100644 --- a/number-of-1-bits/chordpli.py +++ b/number-of-1-bits/chordpli.py @@ -1,3 +1,3 @@ class Solution: def hammingWeight(self, n: int) -> int: - return bin(n).count('1') \ No newline at end of file + return bin(n).count('1') diff --git a/valid-palindrome/chordpli.py b/valid-palindrome/chordpli.py index 0f46eb701..f2582cf40 100644 --- a/valid-palindrome/chordpli.py +++ b/valid-palindrome/chordpli.py @@ -10,4 +10,4 @@ def isPalindrome(self, s: str) -> bool: if lower_eng_str == reverse_str: return True - return False \ No newline at end of file + return False From fbe9a3fb25fc2d41488d5119557773bed1424344 Mon Sep 17 00:00:00 2001 From: pli Date: Sat, 16 Aug 2025 22:23:04 +0900 Subject: [PATCH 5/6] feat: 4 weeks --- maximum-depth-of-binary-tree/chordpli.py | 9 ++++++++ merge-two-sorted-lists/chordpli.py | 29 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 maximum-depth-of-binary-tree/chordpli.py create mode 100644 merge-two-sorted-lists/chordpli.py diff --git a/maximum-depth-of-binary-tree/chordpli.py b/maximum-depth-of-binary-tree/chordpli.py new file mode 100644 index 000000000..15c28b3b0 --- /dev/null +++ b/maximum-depth-of-binary-tree/chordpli.py @@ -0,0 +1,9 @@ +class Solution: + def maxDepth(self, root: Optional[TreeNode]) -> int: + if not root: + return 0 + + right = self.maxDepth(root.right) + left = self.maxDepth(root.left) + + return max(right, left) + 1 diff --git a/merge-two-sorted-lists/chordpli.py b/merge-two-sorted-lists/chordpli.py new file mode 100644 index 000000000..684b690a8 --- /dev/null +++ b/merge-two-sorted-lists/chordpli.py @@ -0,0 +1,29 @@ +# class ListNode: +# def __init__(self, val=0, next=None): +# self.val = val +# self.next = next + + +class Solution: + def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]: + if not list1: + return list2 + + if not list2: + return list1 + + merge_node: ListNode = ListNode() + current = merge_node + + while list1 and list2: + if list1.val < list2.val: + current.next = list1 + list1 = list1.next + else: + current.next = list2 + list2 = list2.next + + current = current.next + + current.next = list1 or list2 + return merge_node.next From f22ae344cde34f12ee2d7520abc3f20a29bf0188 Mon Sep 17 00:00:00 2001 From: pli Date: Sat, 30 Aug 2025 23:41:58 +0900 Subject: [PATCH 6/6] feat: 6 weeks --- valid-parentheses/chordpli.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 valid-parentheses/chordpli.py diff --git a/valid-parentheses/chordpli.py b/valid-parentheses/chordpli.py new file mode 100644 index 000000000..3a8356385 --- /dev/null +++ b/valid-parentheses/chordpli.py @@ -0,0 +1,25 @@ +class Solution: + def isValid(self, s: str) -> bool: + if not s or len(s) % 2 == 1: + return False + + open_symbols = ['(', '[', '{'] + open_box = [] + + for char in list(s): + if char in open_symbols: + open_box.append(char) + elif char not in open_symbols: + if not open_box: + return False + open_symbol = open_box.pop() + if open_symbol == '(' and char == ')': + continue + elif open_symbol == '[' and char == ']': + continue + elif open_symbol == '{' and char == '}': + continue + else: + return False + + return len(open_box) == 0