Skip to content

Commit 9eaa50b

Browse files
committed
64차 3번 문제풀이
1 parent c453918 commit 9eaa50b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

live6/test64/문제3/김진용.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from collections import deque
2+
3+
4+
def solution(cacheSize, cities):
5+
result = 0
6+
if cacheSize == 0: return len(cities) * 5
7+
q = deque(maxlen=cacheSize)
8+
9+
cities = [c.lower() for c in cities]
10+
11+
for city in cities:
12+
if city not in q:
13+
q.append(city)
14+
result += 5
15+
else:
16+
q.remove(city)
17+
q.append(city)
18+
result += 1
19+
20+
return result
21+
22+
23+
print(solution(3, ["Jeju", "Pangyo", "Seoul", "NewYork", "LA", "Jeju", "Pangyo", "Seoul", "NewYork", "LA"]))
24+
print(solution(3, ["Jeju", "Pangyo", "Seoul", "Jeju", "Pangyo", "Seoul", "Jeju", "Pangyo", "Seoul"]))
25+
print(solution(2, ["Jeju", "Pangyo", "Seoul", "NewYork", "LA", "SanFrancisco", "Seoul", "Rome", "Paris", "Jeju", "NewYork", "Rome"] ))
26+
print(solution(5, ["Jeju", "Pangyo", "Seoul", "NewYork", "LA", "SanFrancisco", "Seoul", "Rome", "Paris", "Jeju", "NewYork", "Rome"] ))
27+
print(solution(2, ["Jeju", "Pangyo", "NewYork", "newyork"] ))
28+
print(solution(0, ["Jeju", "Pangyo", "Seoul", "NewYork", "LA"] ))

0 commit comments

Comments
 (0)