https://school.programmers.co.kr/learn/courses/30/lessons/17680
def solution(cacheSize, cities):
cacheMemory = list()
sec = 0
# 1. 캐시 안에 원소가 있는지 확인한다.
for city in cities:
if city.upper() in cacheMemory:
sec += 1
cacheMemory.remove(city.upper())
cacheMemory.append(city.upper())
# 2. 원소가 없으면 시간 5sec 추가
else:
sec += 5
cacheMemory.append(city.upper())
if len(cacheMemory) > cacheSize:
cacheMemory.pop(0)
return sec