From 9c110fcb87e30625162b576aecb8b661666ef0b9 Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:19:33 +0000 Subject: [PATCH 1/2] Create 1733. Minimum Number of People to Teach.py --- ...733. Minimum Number of People to Teach.py" | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 "leetcode3/\354\265\234\354\233\220\354\244\200/1733. Minimum Number of People to Teach.py" diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/1733. Minimum Number of People to Teach.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/1733. Minimum Number of People to Teach.py" new file mode 100644 index 00000000..3af0cd1d --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/1733. Minimum Number of People to Teach.py" @@ -0,0 +1,43 @@ +# + +''' +1. 아이디어 : +서로 소통할 수 없는 사람들을 모아둡니다. +그 사람들 중, 가장 많이 알고 있는 언어를 나머지 사람들에게 가르치면 됩니다. + +2. 시간복잡도 : + O(n*m + k + n*n) + +3. 자료구조/알고리즘 : +- + +''' +class Solution: + def minimumTeachings(self, n: int, languages: list[list[int]], friendships: list[list[int]]) -> int: + m = len(languages) + k = len(friendships) + language_sets = [set(language) for language in languages] + + users = set() + + for a, b in friendships: + a_set = language_sets[a-1] + b_set = language_sets[b-1] + + if a_set & b_set: + continue # can communicate + + users.add(a-1) + users.add(b-1) + + ans = len(users) + + for language in range(1, n+1): + count = 0 + + for user in users: + if language not in language_sets[user]: + count += 1 + + ans = min(ans, count) + return ans From a081deca3cfe53429f18783bdeafc4b619f6865a Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:19:45 +0000 Subject: [PATCH 2/2] Create 3857. Minimum Cost to Split into Ones.py --- .../3857. Minimum Cost to Split into Ones.py" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "leetcode3/\354\265\234\354\233\220\354\244\200/3857. Minimum Cost to Split into Ones.py" diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/3857. Minimum Cost to Split into Ones.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/3857. Minimum Cost to Split into Ones.py" new file mode 100644 index 00000000..23530fd1 --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/3857. Minimum Cost to Split into Ones.py" @@ -0,0 +1,16 @@ +# + +''' +1. 아이디어 : +n을 n-1 + 1로 매번 계산하면 최소값이 됩니다 + +2. 시간복잡도 : + O(n) + +3. 자료구조/알고리즘 : +- + +''' +class Solution: + def minCost(self, n: int) -> int: + return n * (n-1) // 2