Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions leetcode3/오은혁/1733. Minimum Number of People to Teach
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class Solution:
def minimumTeachings(self, n: int, languages: list[list[int]], friendships: list[list[int]]) -> int:
impossible=[]
ans=float('inf')
for u,v in friendships:
if len(set(languages[u-1])&set(languages[v-1]))==0:
impossible.append([u,v])


for l in range(1,n+1):
cnt=0
temp_lang=[set(y) for y in languages]

for u,v in impossible:
if l not in temp_lang[u-1]:
temp_lang[u-1].add(l)
cnt+=1
if l not in temp_lang[v-1]:
temp_lang[v-1].add(l)
cnt+=1
ans=min(ans,cnt)
return ans


15 changes: 15 additions & 0 deletions leetcode3/오은혁/3857. Minimum Cost to Split into Ones
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution:

def minCost(self, n: int) -> int:
if n==1:return 0
if n==2:return 1
dp=[0]*(n+1)
dp[1]=0
dp[2]=1
dp[3]=3
for i in range(4,n+1):
m=float('inf')
for j in range(1,i//2+1):
m=min(m,dp[j]+dp[i-j]+(j*(i-j)))
dp[i]=m
return dp[n]
Loading