From 8c9ccc4ea67932f42277107206c9070686925895 Mon Sep 17 00:00:00 2001 From: 8804 <8804who@naver.com> Date: Sat, 29 Nov 2025 14:35:23 +0900 Subject: [PATCH 1/7] Week 4 --- merge-two-sorted-lists/8804who.py | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 merge-two-sorted-lists/8804who.py diff --git a/merge-two-sorted-lists/8804who.py b/merge-two-sorted-lists/8804who.py new file mode 100644 index 0000000000..32f50fcea4 --- /dev/null +++ b/merge-two-sorted-lists/8804who.py @@ -0,0 +1,36 @@ +# Definition for singly-linked list. +# 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]: + sorted_list = [] + + while True: + if list1 is None and list2 is None: + break + elif list1 is None: + sorted_list.append(list2.val) + list2 = list2.next + elif list2 is None: + sorted_list.append(list1.val) + list1 = list1.next + else: + if list1.val > list2.val: + sorted_list.append(list2.val) + list2 = list2.next + else: + sorted_list.append(list1.val) + list1 = list1.next + + def get_node(idx): + if idx < len(sorted_list): + return ListNode(sorted_list[idx], get_node(idx+1)) + else: + return None + + answer= get_node(0) + + return answer + From ee764227c27c5603de862b5a77e915f0bccb7a58 Mon Sep 17 00:00:00 2001 From: 8804 <8804who@naver.com> Date: Sat, 29 Nov 2025 14:43:16 +0900 Subject: [PATCH 2/7] Week 4 --- maximum-depth-of-binary-tree/8804who.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 maximum-depth-of-binary-tree/8804who.py diff --git a/maximum-depth-of-binary-tree/8804who.py b/maximum-depth-of-binary-tree/8804who.py new file mode 100644 index 0000000000..d7792140f1 --- /dev/null +++ b/maximum-depth-of-binary-tree/8804who.py @@ -0,0 +1,21 @@ +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def maxDepth(self, root: Optional[TreeNode]) -> int: + if not root: + return 0 + + def dfs(node, depth): + l, r = depth, depth + + if node.left: + l = dfs(node.left, depth+1) + if node.right: + r = dfs(node.right, depth+1) + return max(l, r) + + return dfs(root, 1) \ No newline at end of file From ade084a5b7cbe2321a10f22c699c81a3349beba2 Mon Sep 17 00:00:00 2001 From: 8804 <8804who@naver.com> Date: Tue, 2 Dec 2025 22:38:19 +0900 Subject: [PATCH 3/7] Week 4 --- coin-change/8804who.py | 13 ++++++++ .../8804who.py | 14 +++++++++ word-search/8804who.py | 31 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 coin-change/8804who.py create mode 100644 find-minimum-in-rotated-sorted-array/8804who.py create mode 100644 word-search/8804who.py diff --git a/coin-change/8804who.py b/coin-change/8804who.py new file mode 100644 index 0000000000..63059e50c0 --- /dev/null +++ b/coin-change/8804who.py @@ -0,0 +1,13 @@ +class Solution: + def coinChange(self, coins: List[int], amount: int) -> int: + dp = [1e9] * (amount+1) + dp[0] = 0 + + for i in range(1, amount+1): + for coin in coins: + if i-coin>=0: + if dp[i-coin]+1 int: + left = 0 + right = len(nums)-1 + while True: + mid = (left+right)//2 + if nums[left] > nums[right]: + if nums[left] > nums[mid]: + right = mid + else: + left = mid+1 + else: + return nums[left] + diff --git a/word-search/8804who.py b/word-search/8804who.py new file mode 100644 index 0000000000..2bc82a45f0 --- /dev/null +++ b/word-search/8804who.py @@ -0,0 +1,31 @@ +class Solution: + def exist(self, board: List[List[str]], word: str) -> bool: + moves = [[-1, 0], [1, 0], [0, -1], [0, 1]] + max_y, max_x = len(board)-1, len(board[0])-1 + + visited = [[False for _ in range(len(board[0]))] for _ in range(len(board))] + + + def dfs(y, x, idx): + if idx == len(word): + return True + for move in moves: + moved_y, moved_x = y+move[0], x+move[1] + if max_y >= moved_y and moved_y >= 0 and max_x >= moved_x and moved_x >= 0: + if board[moved_y][moved_x] == word[idx] and not visited[moved_y][moved_x]: + visited[moved_y][moved_x] = True + if dfs(moved_y, moved_x, idx+1): + return True + visited[moved_y][moved_x] = False + + + for y in range(max_y+1): + for x in range(max_x+1): + if board[y][x] == word[0]: + visited[y][x] = True + if dfs(y, x, 1): + return True + visited[y][x] = False + + return False + From 8854d7e27e94bbd5c3aa2e0b003629e0688d77c3 Mon Sep 17 00:00:00 2001 From: 8804 <8804who@naver.com> Date: Tue, 2 Dec 2025 22:40:58 +0900 Subject: [PATCH 4/7] Week 4 --- maximum-depth-of-binary-tree/8804who.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maximum-depth-of-binary-tree/8804who.py b/maximum-depth-of-binary-tree/8804who.py index d7792140f1..4b6ff51e7c 100644 --- a/maximum-depth-of-binary-tree/8804who.py +++ b/maximum-depth-of-binary-tree/8804who.py @@ -18,4 +18,5 @@ def dfs(node, depth): r = dfs(node.right, depth+1) return max(l, r) - return dfs(root, 1) \ No newline at end of file + return dfs(root, 1) + From 7c255309a14d3ccdae541513e0997f061ff256d0 Mon Sep 17 00:00:00 2001 From: 8804 <8804who@naver.com> Date: Thu, 4 Dec 2025 21:41:34 +0900 Subject: [PATCH 5/7] Week 5 --- best-time-to-buy-and-sell-stock/8804who.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 best-time-to-buy-and-sell-stock/8804who.py diff --git a/best-time-to-buy-and-sell-stock/8804who.py b/best-time-to-buy-and-sell-stock/8804who.py new file mode 100644 index 0000000000..8eb447965a --- /dev/null +++ b/best-time-to-buy-and-sell-stock/8804who.py @@ -0,0 +1,12 @@ +class Solution: + def maxProfit(self, prices: List[int]) -> int: + answer = 0 + + min_price = prices[0] + for price in prices: + if min_price>price: + min_price=price + + if answer Date: Thu, 4 Dec 2025 21:55:17 +0900 Subject: [PATCH 6/7] Week 5 --- group-anagrams/8804who.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 group-anagrams/8804who.py diff --git a/group-anagrams/8804who.py b/group-anagrams/8804who.py new file mode 100644 index 0000000000..6cb3968971 --- /dev/null +++ b/group-anagrams/8804who.py @@ -0,0 +1,8 @@ +class Solution: + def groupAnagrams(self, strs: List[str]) -> List[List[str]]: + dic=defaultdict(list) + for string in strs: + sorted_str = ''.join(sorted(string)) + dic[sorted_str].append(string) + + return list(dic.values()) \ No newline at end of file From 042bcf598afe4603029efa8278cd724acaa5aaaf Mon Sep 17 00:00:00 2001 From: 8804 <8804who@naver.com> Date: Fri, 5 Dec 2025 22:20:20 +0900 Subject: [PATCH 7/7] Week 5 --- best-time-to-buy-and-sell-stock/8804who.py | 3 ++- group-anagrams/8804who.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/best-time-to-buy-and-sell-stock/8804who.py b/best-time-to-buy-and-sell-stock/8804who.py index 8eb447965a..a41ce83349 100644 --- a/best-time-to-buy-and-sell-stock/8804who.py +++ b/best-time-to-buy-and-sell-stock/8804who.py @@ -9,4 +9,5 @@ def maxProfit(self, prices: List[int]) -> int: if answer List[List[str]]: sorted_str = ''.join(sorted(string)) dic[sorted_str].append(string) - return list(dic.values()) \ No newline at end of file + return list(dic.values()) +