From 10410e5ff9a54202b765c46f514accf5fdc41cf7 Mon Sep 17 00:00:00 2001 From: doh6077 Date: Sun, 18 Jan 2026 12:55:32 -0500 Subject: [PATCH 1/5] Missing Number Solution --- missing-number/doh6077.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 missing-number/doh6077.py diff --git a/missing-number/doh6077.py b/missing-number/doh6077.py new file mode 100644 index 0000000000..6b2aeb3cb1 --- /dev/null +++ b/missing-number/doh6077.py @@ -0,0 +1,16 @@ +# Missing Number +class Solution: + def missingNumber(self, nums: List[int]) -> int: + # First Solution: Time Complexity: O(n^2) + n = len(nums) + + for i in range(0,n + 1): + if i not in nums: + return i + + # Time Complexity: O(n) + n = len(nums) + # calculate the sum of first n numbers + sum_val = n * (n + 1) // 2 + return sum_val - sum(nums) + From 0f534261d0d2961f34f861e561269aa29e587118 Mon Sep 17 00:00:00 2001 From: doh6077 Date: Sun, 18 Jan 2026 13:47:22 -0500 Subject: [PATCH 2/5] 143. Reorder List Solution --- reorder-list/doh6077.py | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 reorder-list/doh6077.py diff --git a/reorder-list/doh6077.py b/reorder-list/doh6077.py new file mode 100644 index 0000000000..6c8519fefb --- /dev/null +++ b/reorder-list/doh6077.py @@ -0,0 +1,43 @@ +# Definition for singly-linked list. +# class ListNode: +# def __init__(self, val=0, next=None): +# self.val = val +# self.next = next +class Solution: + def reorderList(self, head: Optional[ListNode]) -> None: + """ + Do not return anything, modify head in-place instead. + """ + # Time Complexity: O(N) + # The order: + # 0, n, 1, n -1, 2, n-3 ... + # first Idea + # need to save the index of the original head + # Hashmap: iterate through the head until head it none, save index as key and head.val as value + head_hash = {} + temp = head + index = 0 + length = 0 + # Save index and value in the hashmap + while temp is not None: + head_hash[index] = temp.val + temp = temp.next + index += 1 + length += 1 + # reset index to 0, and use it to iterate through the head again + index = 0 + # to keep track of n-1, n-2, n-3 ... + count = 1 + # Iterate through the head again and change the value based on the index + while head is not None: + res = index % 2 + # if the index is even number + if res == 0: + head.val = head_hash[index/2] + # n, n-1, n-2 when the index is odd + else: + head.val = head_hash[length - count] + count += 1 + index += 1 + head = head.next + \ No newline at end of file From a07710ca3f88dba0616387690fb2969ae665ce87 Mon Sep 17 00:00:00 2001 From: doh6077 Date: Sun, 18 Jan 2026 13:48:33 -0500 Subject: [PATCH 3/5] =?UTF-8?q?=EC=A4=84=EB=B0=94=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reorder-list/doh6077.py | 1 - 1 file changed, 1 deletion(-) diff --git a/reorder-list/doh6077.py b/reorder-list/doh6077.py index 6c8519fefb..70d9417451 100644 --- a/reorder-list/doh6077.py +++ b/reorder-list/doh6077.py @@ -40,4 +40,3 @@ def reorderList(self, head: Optional[ListNode]) -> None: count += 1 index += 1 head = head.next - \ No newline at end of file From 144ee0d6018e35b6136e26f0e685d65e4a3c1bf8 Mon Sep 17 00:00:00 2001 From: doh6077 Date: Mon, 19 Jan 2026 12:38:37 -0500 Subject: [PATCH 4/5] graph Valid Tree solution --- graph-valid-tree/doh6077.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 graph-valid-tree/doh6077.py diff --git a/graph-valid-tree/doh6077.py b/graph-valid-tree/doh6077.py new file mode 100644 index 0000000000..97076f7f51 --- /dev/null +++ b/graph-valid-tree/doh6077.py @@ -0,0 +1,33 @@ +class Solution: + def validTree(self, n: int, edges: List[List[int]]) -> bool: + # Valid Tree + # 1. no loop + # 2. no disconnected node + # Use DFS and Hashset to track visited nodes + if not n: + return True + + adj = {i:[] for i in range(n)} + for n1, n2 in edges: + adj[n1].append(n2) + adj[n2].append(n1) + visit = set() + def dfs(i, prev): + # Base case + if i in visit: + return False + visit.add(i) + # check neighbor nodes + for j in adj[i]: + if j == prev: + continue + if not dfs(j,i): + return False + return True + + return dfs(0, -1) and n == len(visit) + + + + + From 617abb3dce95fdb6488e31b522e5fb4cb20d6994 Mon Sep 17 00:00:00 2001 From: doh6077 Date: Mon, 19 Jan 2026 12:39:04 -0500 Subject: [PATCH 5/5] =?UTF-8?q?=EC=A4=84=EB=B0=94=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- graph-valid-tree/doh6077.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/graph-valid-tree/doh6077.py b/graph-valid-tree/doh6077.py index 97076f7f51..7739a13b43 100644 --- a/graph-valid-tree/doh6077.py +++ b/graph-valid-tree/doh6077.py @@ -26,8 +26,3 @@ def dfs(i, prev): return True return dfs(0, -1) and n == len(visit) - - - - -