From bfd741f6266bd8d41176dfd54fa1be38b5c18b18 Mon Sep 17 00:00:00 2001 From: Gordon Choi Date: Fri, 26 Dec 2025 15:41:30 +0900 Subject: [PATCH 1/5] reverse linked list solution --- reverse-linked-list/radiantchoi.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 reverse-linked-list/radiantchoi.ts diff --git a/reverse-linked-list/radiantchoi.ts b/reverse-linked-list/radiantchoi.ts new file mode 100644 index 000000000..5b98b2c93 --- /dev/null +++ b/reverse-linked-list/radiantchoi.ts @@ -0,0 +1,24 @@ +// 문제에서 주어진 ListNode +class ListNode { + val: number + next: ListNode | null + + constructor(val?: number, next?: ListNode | null) { + this.val = (val===undefined ? 0 : val) + this.next = (next===undefined ? null : next) + } +} + +function reverseList(head: ListNode | null): ListNode | null { + let current = null; + + // 매번 새로운 노드를 생성하고, 지금까지 순회한 모든 결과를 이 새로운 노드의 next로 연결 + while (head !== null) { + const newNode = new ListNode(head.val); + newNode.next = current; + current = newNode; + head = head.next; + } + + return current; +}; From 9699ecd8702745999d80f2f6d3661abb54ff50f7 Mon Sep 17 00:00:00 2001 From: Gordon Choi Date: Fri, 26 Dec 2025 16:13:54 +0900 Subject: [PATCH 2/5] number of islands solution --- number-of-islands/radiantchoi.swift | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 number-of-islands/radiantchoi.swift diff --git a/number-of-islands/radiantchoi.swift b/number-of-islands/radiantchoi.swift new file mode 100644 index 000000000..5d06e1752 --- /dev/null +++ b/number-of-islands/radiantchoi.swift @@ -0,0 +1,40 @@ +class Solution { + func numIslands(_ grid: [[Character]]) -> Int { + var grid = grid + var result = 0 + + for i in 0.. Date: Fri, 26 Dec 2025 16:35:11 +0900 Subject: [PATCH 3/5] set matrix zeroes solutions --- set-matrix-zeroes/radiantchoi.swift | 75 +++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 set-matrix-zeroes/radiantchoi.swift diff --git a/set-matrix-zeroes/radiantchoi.swift b/set-matrix-zeroes/radiantchoi.swift new file mode 100644 index 000000000..1db63dd02 --- /dev/null +++ b/set-matrix-zeroes/radiantchoi.swift @@ -0,0 +1,75 @@ +class Solution { + func setZeroes(_ matrix: inout [[Int]]) { + // 원래 0이었던 것의 주변을 모두 0으로 만들되, 기존에 0이었던 것들은 독립적으로 영향력을 행사해야 함 + // 주변으로 먼저 0으로 만들어 버리면, flood fill 형태로 모든 원소가 0이 되어버림 + // 따라서 변경해야 할 값을 미리 "마크해 두고", 이후 이 마크해 둔 값을 0으로 바꾸는 전략 선택 + + // 원소 값의 범위: -2^31보다 크거나 같고, 2^31 - 1보다 작거나 같음 + // 따라서 범위에 포함되지 않는 2^32를 사용하여 계산 - 일부 언어에서는 overflow 발생 가능 + let threshold = Int(pow(2.0, 32)) + + for i in 0.. Date: Fri, 26 Dec 2025 17:14:53 +0900 Subject: [PATCH 4/5] longest substring without repeating characters solution --- .../radiantchoi.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 longest-substring-without-repeating-characters/radiantchoi.py diff --git a/longest-substring-without-repeating-characters/radiantchoi.py b/longest-substring-without-repeating-characters/radiantchoi.py new file mode 100644 index 000000000..15973dfd0 --- /dev/null +++ b/longest-substring-without-repeating-characters/radiantchoi.py @@ -0,0 +1,30 @@ +class Solution: + def lengthOfLongestSubstring(self, s: str) -> int: + # 문자열 전체를 순회, 서브스트링이란 서로 붙어 있는 문자열 + # 글자를 볼 때 현재 모아둔 글자 모음에 중복 글자가 있다면? + # 일단 지금까지의 길이 업데이트 + # 중복된 글자가 등장한 인덱스 체크 + # 현재 모아둔 문자열의 길이에서 해당 인덱스까지의 "머리"를 덜어내고 지금 보는 문자를 더해서, 서브스트링을 이어나감 + + current = {} + tuning = 0 + result = 0 + + for (index, letter) in enumerate(s): + if current.get(letter, index) < index: + result = max(result, len(current)) + + tail_of_head = current[letter] + + new_current = {} + for key in current: + if current[key] > tail_of_head: + new_current[key] = current[key] + + current = new_current + + current[letter] = index + + result = max(result, len(current)) + + return result From aa2d942f7f89473076b26b30b1c88cdbadb0e65a Mon Sep 17 00:00:00 2001 From: Gordon Choi Date: Fri, 26 Dec 2025 17:57:48 +0900 Subject: [PATCH 5/5] unique paths solution --- unique-paths/radiantchoi.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 unique-paths/radiantchoi.py diff --git a/unique-paths/radiantchoi.py b/unique-paths/radiantchoi.py new file mode 100644 index 000000000..2873b96c7 --- /dev/null +++ b/unique-paths/radiantchoi.py @@ -0,0 +1,10 @@ +import math + +class Solution: + def uniquePaths(self, m: int, n: int) -> int: + # 도착을 위해 실제로 움직여야 하는 칸은 아래로 (m - 1)칸, 오른쪽으로 (n - 1)칸 + # 총 (m + 1) + (n + 1)칸을 움직여야 하는데, 이만큼의 "빈 바구니"가 있다고 가정 + # 빈 바구니의 몇 번 박스에 오른쪽으로 가기/아래로 가기를 넣을 것인가? 의 문제 + # 조합을 통해 둘 중 아무거나를 바구니에 넣는 경우의 수를 구하면, 나머지 칸에 나머지 하나를 다 넣을 수 있다. + # 따라서 math.comb(m + n - 2, n - 1)도 동일한 결과 반환 + return math.comb(m + n - 2, m - 1)