From 5b75f4629c0a0066f847061698fdd4fa27c19a4f Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Mon, 24 Aug 2026 22:35:52 +0900 Subject: [PATCH 1/3] Create 3014. Minimum Number of Pushes to Type Word I.py --- ...4. Minimum Number of Pushes to Type Word I.py" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "leetcode3/\354\265\234\354\233\220\354\244\200/3014. Minimum Number of Pushes to Type Word I.py" diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/3014. Minimum Number of Pushes to Type Word I.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/3014. Minimum Number of Pushes to Type Word I.py" new file mode 100644 index 00000000..f0124b07 --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/3014. Minimum Number of Pushes to Type Word I.py" @@ -0,0 +1,15 @@ +class Solution: + def minimumPushes(self, word: str) -> int: + counter = Counter(word) + freq_num = [[freq, num] for num, freq in counter.items()] + freq_num.sort() + + ans = 0 + counter = 0 + + while freq_num: + freq, num = freq_num.pop() + cost = counter // 8 + 1 + counter+=1 + ans+=cost * freq + return ans From 0ee512b36ff70eb6f5aeea6b89abb90b51a8510d Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Tue, 25 Aug 2026 22:25:59 +0900 Subject: [PATCH 2/3] Fix time complexity notation in Compute Alternating Sum Updated time complexity notation to O(n + n). --- .../3701. Compute Alternating Sum.py" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "leetcode3/\354\265\234\354\233\220\354\244\200/3701. Compute Alternating Sum.py" diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/3701. Compute Alternating Sum.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/3701. Compute Alternating Sum.py" new file mode 100644 index 00000000..54ae41b1 --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/3701. Compute Alternating Sum.py" @@ -0,0 +1,16 @@ +# + +''' +1. 아이디어 : + + +2. 시간복잡도 : + O(n + n) + +3. 자료구조/알고리즘 : + + +''' +class Solution: + def alternatingSum(self, nums: List[int]) -> int: + return sum([nums[i] if i%2==0 else -nums[i] for i in range(len(nums))]) From 95357fa88f3129e76ff643c5c618c2abccaed5c7 Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Tue, 25 Aug 2026 22:28:42 +0900 Subject: [PATCH 3/3] Create 785. Is Graph Bipartite?.py --- .../785. Is Graph Bipartite?.py" | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "leetcode3/\354\265\234\354\233\220\354\244\200/785. Is Graph Bipartite?.py" diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/785. Is Graph Bipartite?.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/785. Is Graph Bipartite?.py" new file mode 100644 index 00000000..51d6eb9e --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/785. Is Graph Bipartite?.py" @@ -0,0 +1,45 @@ +# + +''' +1. 아이디어 : +Bipartite는 그래프에서 노드들을 2가지 색을 칠했을때, 인접한 노드와 다른 색일때 성립. +bfs를 통해 노드들의 색갈을 0 또는 1로 칠한다. +그래프가 끊긴 문제는 모든 노드들을 순회하게끔 한다. + +2. 시간복잡도 : + O(V + E) 노드, 간선 + +3. 자료구조/알고리즘 : +BFS + +''' +class Solution: + def isBipartite(self, graph: List[List[int]]) -> bool: + n = len(graph) + colors = [-1] * n + + for i in range(n): + if colors[i] != -1: + continue + + colors[i] = 0 + queue = deque() + queue.append(i) + + while queue: + start = queue.popleft() + start_color = colors[start] + + for dest in graph[start]: + dest_color = colors[dest] + if start_color == dest_color: + return False + + if dest_color == -1: + queue.append(dest) + colors[dest] = (1 + start_color) % 2 + # print(colors) + return True + + +