From 8d23c1d6efef62b8b46dcb843628f508720955de Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Tue, 1 Dec 2026 22:21:25 +0900 Subject: [PATCH 1/2] Create 926. Flip String to Monotone Increasing.py --- ...26. Flip String to Monotone Increasing.py" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "leetcode3/\354\265\234\354\233\220\354\244\200/926. Flip String to Monotone Increasing.py" diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/926. Flip String to Monotone Increasing.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/926. Flip String to Monotone Increasing.py" new file mode 100644 index 00000000..8aa94b03 --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/926. Flip String to Monotone Increasing.py" @@ -0,0 +1,33 @@ +# + +''' +1. 아이디어 : +뒤에서부터 index i까지 0일때 바꿔야하는 갯수를 counter로 구합니다 +앞에서부터 i번째까지 0일때 뒤집어야하는 갯수 + i+1번쨰부터 끝까지 1일떄의 갯수를 구합니다 + +2. 시간복잡도 : + O(n + n) + +3. 자료구조/알고리즘 : +- + +''' +class Solution: + def minFlipsMonoIncr(self, s: str) -> int: + n = len(s) + counter = [0] * n + total = 0 + for i in range(n-1,-1,-1): + if s[i] == "0": + total += 1 + counter[i] = total + + + ans = float('inf') + total = 0 + for i in range(n): + ans = min(ans, total+ counter[i]) + if s[i] == "1": + total += 1 + return min(ans, total) + From 8bb531b9a0bceed7c8623cd7e984b324244c35ce Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Tue, 1 Dec 2026 22:21:36 +0900 Subject: [PATCH 2/2] Create 1233. Remove Sub-Folders from the Filesystem.py --- ...Remove Sub-Folders from the Filesystem.py" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "leetcode3/\354\265\234\354\233\220\354\244\200/1233. Remove Sub-Folders from the Filesystem.py" diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/1233. Remove Sub-Folders from the Filesystem.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/1233. Remove Sub-Folders from the Filesystem.py" new file mode 100644 index 00000000..95dfe151 --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/1233. Remove Sub-Folders from the Filesystem.py" @@ -0,0 +1,23 @@ +# + +''' +1. 아이디어 : +정렬하면 sub-folder가 항상 뒤에 오게 됩니다. + +2. 시간복잡도 : + O(nlogn + n) + +3. 자료구조/알고리즘 : +정렬. + +''' +class Solution: + def removeSubfolders(self, folder: list[str]) -> list[str]: + folder.sort() + ans = [] + + for path in folder: + if ans and path.startswith(ans[-1] + "/"): + continue + ans.append(path) + return ans