From 2c7db9e9c48d543cd8c79bb521aec36da866229d Mon Sep 17 00:00:00 2001 From: YOUNGJIN NA <120540450+ppxyn1@users.noreply.github.com> Date: Sun, 18 Jan 2026 12:37:15 +0900 Subject: [PATCH 1/2] [:solved] #235 --- missing-number/ppxyn1.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 missing-number/ppxyn1.py diff --git a/missing-number/ppxyn1.py b/missing-number/ppxyn1.py new file mode 100644 index 0000000000..7675528a70 --- /dev/null +++ b/missing-number/ppxyn1.py @@ -0,0 +1,12 @@ +# idea : - +# Time Complexity : below O(n^2) + +class Solution: + def missingNumber(self, nums: List[int]) -> int: + nums.sort() + for i in range(len(nums)): + if nums[i] != i: + return i + return len(nums) + + From b632f876c99df9e11f0d510b5efa91df9ea26115 Mon Sep 17 00:00:00 2001 From: YOUNGJIN NA <120540450+ppxyn1@users.noreply.github.com> Date: Fri, 23 Jan 2026 18:23:49 +0900 Subject: [PATCH 2/2] [:solved] #247, #278 --- merge-intervals/ppxyn1.py | 17 ++++++++++++++++ reorder-list/ppxyn1.py | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 merge-intervals/ppxyn1.py create mode 100644 reorder-list/ppxyn1.py diff --git a/merge-intervals/ppxyn1.py b/merge-intervals/ppxyn1.py new file mode 100644 index 0000000000..5d169b48f6 --- /dev/null +++ b/merge-intervals/ppxyn1.py @@ -0,0 +1,17 @@ +# idea : - +# TimeComplexity: # O(n log(n)) +class Solution: + def merge(self, intervals: List[List[int]]) -> List[List[int]]: + intervals = sorted(intervals) + output = [intervals[0]] + + # Merge when intervals overlap + for start, end in intervals[1:]: + lastEnd = output[-1][1] + if start <= lastEnd: + output[-1][1] = max(lastEnd, end) + else: + output.append([start, end]) + return output + + diff --git a/reorder-list/ppxyn1.py b/reorder-list/ppxyn1.py new file mode 100644 index 0000000000..3fc6702244 --- /dev/null +++ b/reorder-list/ppxyn1.py @@ -0,0 +1,43 @@ +# idea: Two-Pointer +# Time Complexixty: O(n)? +''' +Linked lists do not provide a len func, split at the middle and merge the two halves sequentially +''' + +# 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): + if not head or not head.next: + return + + # 1. middle + slow, fast = head, head + while fast and fast.next: + slow = slow.next + fast = fast.next.next + + # 2. reverse second half + prev = None + cur = slow.next + slow.next = None + + while cur: + nxt = cur.next + cur.next = prev + prev = cur + cur = nxt + + # 3. merge + first, second = head, prev + while second: + t1, t2 = first.next, second.next + first.next = second + second.next = t1 + first = t1 + second = t2 + +