
Programmers / 2단계 / 캐시 / python
·
Coding Test/Programmers
코딩테스트 연습 - [1차] 캐시 | 프로그래머스 스쿨 (programmers.co.kr) 나의 풀이 . 모범 답안 def solution(cacheSize, cities): cache = [] time = 0 for city in cities: city = city.lower() if cacheSize: if not city in cache: if len(cache) == cacheSize: cache.pop(0) cache.append(city) time += 5 else: cache.pop(cache.index(city)) cache.append(city) time += 1 else: time += 5 return time LRU : 가장 오랫동안 참조되지 않은 페이지를 교체 LRU 예시) 캐시크기..