From 63cb3976dc6cbd0aee23c7ffd7562c6d0524d3cb Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Mon, 13 Jul 2026 13:57:05 +0900 Subject: [PATCH 1/4] Solve: mergeTwoLists --- merge-two-sorted-lists/daehyun99.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 merge-two-sorted-lists/daehyun99.py diff --git a/merge-two-sorted-lists/daehyun99.py b/merge-two-sorted-lists/daehyun99.py new file mode 100644 index 0000000000..cf35919c2a --- /dev/null +++ b/merge-two-sorted-lists/daehyun99.py @@ -0,0 +1,25 @@ +# 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]: + # Space: O(N) + # Time: O(N) + dummy = ListNode(val=0, next=None) + pointer = dummy + while (list1 is not None) and (list2 is not None): + if list1.val <= list2.val: + pointer.next = ListNode(list1.val) + list1 = list1.next + else: + pointer.next = ListNode(list2.val) + list2 = list2.next + pointer = pointer.next + if list1 is not None: + pointer.next = list1 + elif list2 is not None: + pointer.next = list2 + + return dummy.next From 3d524085748ecd27b4c744662f8e7c44e75707c9 Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Tue, 14 Jul 2026 14:28:36 +0900 Subject: [PATCH 2/4] Solve: maxDepth --- maximum-depth-of-binary-tree/daehyun99.py | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 maximum-depth-of-binary-tree/daehyun99.py diff --git a/maximum-depth-of-binary-tree/daehyun99.py b/maximum-depth-of-binary-tree/daehyun99.py new file mode 100644 index 0000000000..a049391a8a --- /dev/null +++ b/maximum-depth-of-binary-tree/daehyun99.py @@ -0,0 +1,43 @@ +# 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: + count = 0 + stacks1 = [root] + stacks2= [] + + if root is None: + return count + while len(stacks1) > 0 : + count += 1 + while len(stacks1) > 0 : + node = stacks1.pop() + + if node.left is not None: + stacks2.append(node.left) + if node.right is not None: + stacks2.append(node.right) + stacks1.extend(stacks2) + stacks2 = [] + return count + +""" +class Solution: + def maxDepth(self, root: Optional[TreeNode]) -> int: + def depth(node, dep): + if (node.left is None) and (node.right is None): + return dep + if (node.left is not None) and (node.right is None): + return depth(node.left, dep+1) + if (node.left is None) and (node.right is not None): + return depth(node.right, dep+1) + else: + return max(depth(node.left, dep+1), depth(node.right, dep+1)) + if root is None: + return 0 + return depth(root, 1) +""" From f25dcc6428606dccf2ba2d59d7aae7fee02d5626 Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Wed, 15 Jul 2026 14:17:04 +0900 Subject: [PATCH 3/4] Solve: findMin --- .../daehyun99.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 find-minimum-in-rotated-sorted-array/daehyun99.py diff --git a/find-minimum-in-rotated-sorted-array/daehyun99.py b/find-minimum-in-rotated-sorted-array/daehyun99.py new file mode 100644 index 0000000000..0338fc600b --- /dev/null +++ b/find-minimum-in-rotated-sorted-array/daehyun99.py @@ -0,0 +1,18 @@ +class Solution: + def findMin(self, nums: List[int]) -> int: + if len(nums) == 1: + return nums[0] + + while True: + if nums[-1] < nums[0]: + nums[0] = nums.pop() + else: + break + + return nums[0] + +""" +class Solution: + def findMin(self, nums: List[int]) -> int: + return min(nums) +""" From 2f799bbce7b5fa7e6243f3c19cfd74270c8599f6 Mon Sep 17 00:00:00 2001 From: daehyun99 Date: Thu, 16 Jul 2026 15:51:31 +0900 Subject: [PATCH 4/4] Solve: exist --- word-search/daehyun99.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 word-search/daehyun99.py diff --git a/word-search/daehyun99.py b/word-search/daehyun99.py new file mode 100644 index 0000000000..b746bb4e4b --- /dev/null +++ b/word-search/daehyun99.py @@ -0,0 +1,33 @@ +from collections import defaultdict +class Solution: + def exist(self, board: List[List[str]], word: str) -> bool: + pos = defaultdict(list) + for i in range(len(board)): + for j in range(len(board[0])): + if board[i][j] in word: + tmp = pos.get(board[i][j], []) + tmp.append([i, j]) + pos[board[i][j]] = tmp + + paths = pos.get(word[0], []) + paths = [[path] for path in paths] + + for w in word[1:]: + temp = [] + + while len(paths) > 0: + path = paths.pop() + i , j = path[-1] + if ([i, j+1] in pos[w]) and ([i, j+1] not in path): + temp.append(path[:] + [[i, j+1]]) + if ([i, j-1] in pos[w]) and ([i, j-1] not in path): + temp.append(path[:] + [[i, j-1]]) + if ([i+1, j] in pos[w]) and ([i+1, j] not in path): + temp.append(path[:] + [[i+1, j]]) + if ([i-1, j] in pos[w]) and ([i-1, j] not in path): + temp.append(path[:] + [[i-1, j]]) + paths.extend(temp) + for path in paths: + if len(path) == len(word): + return True + return False