From 96091cf374023e1f625dcc1c02266d92fdca255a Mon Sep 17 00:00:00 2001 From: rimogsu Date: Thu, 5 Nov 2026 22:50:40 +0900 Subject: [PATCH] 1733,3857 --- ...733. Minimum Number of People to Teach.py" | 35 +++++++++++++++++++ .../3857. Minimum Cost to Split into Ones.py" | 20 +++++++++++ 2 files changed, 55 insertions(+) create mode 100644 "leetcode3/\353\263\200\354\247\200\355\230\221/v4/1733. Minimum Number of People to Teach.py" create mode 100644 "leetcode3/\353\263\200\354\247\200\355\230\221/v4/3857. Minimum Cost to Split into Ones.py" diff --git "a/leetcode3/\353\263\200\354\247\200\355\230\221/v4/1733. Minimum Number of People to Teach.py" "b/leetcode3/\353\263\200\354\247\200\355\230\221/v4/1733. Minimum Number of People to Teach.py" new file mode 100644 index 00000000..88bed975 --- /dev/null +++ "b/leetcode3/\353\263\200\354\247\200\355\230\221/v4/1733. Minimum Number of People to Teach.py" @@ -0,0 +1,35 @@ +from collections import defaultdict +class Solution: + def minimumTeachings(self, n: int, languages: list[list[int]], friendships: list[list[int]]) -> int: + tmp = [] + for a,b in friendships: + tmp.append((a-1,b-1)) + + dic = defaultdict(list) + + for a,b in tmp: + a_lan = set(languages[a]) + b_lan = set(languages[b]) + + overlap = a_lan & b_lan + if not overlap: + dic[a].append(b) + dic[b].append(a) + + print(dic) + + for i in range(n): + most_freq = defaultdict(int) + for friend in dic[i]: + for j in languages[i]: + most_freq[j] += 1 + + most_freq = sorted(most_freq.items(), key=lambda x:x[1], reverse=True) + + for key,value in most_freq: + + + print(most_freq) + + + diff --git "a/leetcode3/\353\263\200\354\247\200\355\230\221/v4/3857. Minimum Cost to Split into Ones.py" "b/leetcode3/\353\263\200\354\247\200\355\230\221/v4/3857. Minimum Cost to Split into Ones.py" new file mode 100644 index 00000000..000b473f --- /dev/null +++ "b/leetcode3/\353\263\200\354\247\200\355\230\221/v4/3857. Minimum Cost to Split into Ones.py" @@ -0,0 +1,20 @@ +class Solution: + def minCost(self, n: int) -> int: + dic = {} + dic[1] = 0 + dic[2] = 1 + dic[3] = 3 + dic[4] = 6 + + for i in range(5,n+1): + a = 1 + b = i - 1 + tmp = 10e9 + while a < b: + tmp = min(tmp, a * b + dic[a] + dic[b]) + a+=1 + b-=1 + dic[i] = tmp + + return dic[n] + \ No newline at end of file