스택2
-
[리트코드] 739. Daily Temperatures
문제 링크https://leetcode.com/problems/daily-temperatures/description/느낀 점어떻게든 ON2이 안되는 방법을 생각해내야하는데, 지금까지 가장 큰 시점보다 더 올라간 시점을 찾았을 때, 이전에 이 점 보다 더 작은 점들을 계산해주는 방식으로 구했음. 솔직히 처음 문제를 보고 이렇게 딱 생각하기는 쉽지 않을 것 같다..from typing import Listimport collectionsclass Solution: def dailyTemperaturesself,T:List[int] -> List[int]: count = [0 for _ in rangelen(T)] stack = [] T = co..
2024.07.11 -
[백준] 1374 - 강의실
# stack이나 정렬 문제라고해서 완전히 그 형태로 만들어야된다는 생각은 버리고 규칙, 제약 조건을 먼저 생각해보자import sysimport heapqN = intsys.stdin.readline()time_list = [[] for _ in rangeN]pq = []num_lectures = 0for ind in rangeN: _, time_s, time_e = mapint,sys.stdin.readline(.split) time_list[ind].appendtimes time_list[ind].appendtimeetime_list = sortedtimelist,key=lambdax:(x[0],x[1])for ind in range(N..
2024.05.14