From 10410e5ff9a54202b765c46f514accf5fdc41cf7 Mon Sep 17 00:00:00 2001 From: doh6077 Date: Sun, 18 Jan 2026 12:55:32 -0500 Subject: [PATCH 1/3] 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/3] 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/3] =?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