반응형 알고리즘65 [파이썬][프로그래머스] 완전탐색 최소직사각형 def solution(sizes): answer = 0 max_w = 0 max_h = 0 # for 문 왼쪽 오른쪽중 큰쪽 따로 작은쪽 따로해서 2분류된곳중 가장 큰 값을 곱해준다 for size in sizes: if size[0] max_w: max_w = max_size if min_size > max_h: max_h = min_size answer = max_w * max_h return answer 2022. 11. 24. [파이썬][프로그래머스] 정렬 H-Index def solution(citations): answer = 0 for i in range(max(citations)+1): count = 0 for j in range(len(citations)): if i = i: answer = i return answer 2022. 11. 23. [파이썬][프로그래머스] 정렬 K번째수 def solution(array, commands): answer = [] for command in commands: temp = sorted(array[command[0]-1:command[1]]) answer.append(temp[command[2]-1]) return answer 2022. 11. 22. [파이썬][프로그래머스] 힙(Heap) 이중우선순위큐 from heapq import heappush, heappop, nlargest def solution(operations): answer = [] for operation in operations: standard, queue = operation.split(' ') if standard == 'I': heappush(answer, int(queue)) else: if len(answer) == 0: pass elif len(answer) == 1: heappop(answer) else: if queue == '-1': heappop(answer) else: temp = [] count = len(answer) for i in range(count-1): heappush(temp, heappop(an.. 2022. 11. 21. 이전 1 2 3 4 5 6 ··· 17 다음 반응형