Algorithem/프로그래머스 PS with code

Algorithem/프로그래머스 PS with code

[python3] H-index lv.2

풀이 1) 오름차순 정렬 def solution(citations): citations.sort() total = len(citations) for i in range(total) : if total-i 7개 2번 이상 -> 6개 3번 이상 -> 5개 (4번 이상 -> 4개) (5번 이상 -> 4개) 7번 이상 -> 4개 이때 h index 는 볼드친 4개가 된다. if 문에 안들어가는 경우는 citations 배열이 0 으로만 구성되는 경우다. -> return 0 풀이 2) 내림차순 정렬 def solution(citations): citations.sort(reverse = True) for i in range(len(citations)) : if citations[i] < (i+1) : retur..

Algorithem/프로그래머스 PS with code

[python3] 멀리 뛰기 lv.2

시도 1) nCm 으로 해결해보려,, 했는데 def nCm(n,m) : if m == 0 : return 1 else : r = 1 for i in range(n-m+1,n+1) : r*=i t = 1 for i in range(1,m+1) : t*=i return r//t def solution(n): one = n two = 0 summ = 0 while one >= 0 : summ += nCm(one+two, min(one,two)) one-=2 two+=1 return summ%1234567 # 나머지를 구하는 문제. 문제 잘읽자 풀이) (점화식) 피보나치 1 -> (1) : 1 2 -> (1,1), (2) : 2 3 -> (1,1,1), (1,2), (2,1) : 3 4 -> (1,1,1,1),..

Algorithem/프로그래머스 PS with code

[python3] 점프와 순간이동 lv.2

풀이 1) 다이나믹 lst = [0]*1000000001 def check(stack, n) : global lst nstack = [] while stack : p = stack.pop() if lst[p+1] == 0 : i = lst[p]+1 p+=1 while p

jamong5
'Algorithem/프로그래머스 PS with code' 카테고리의 글 목록 (2 Page)