Skip to content

Commit

Permalink
2024-03-01 ์บ์‹œ
Browse files Browse the repository at this point in the history
  • Loading branch information
kjs254 committed Mar 1, 2024
1 parent 25ce19e commit 3267c9c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
10 changes: 6 additions & 4 deletions kjs254/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
|:----:|:---------:|:----:|:-----:|:----:|
| 1์ฐจ์‹œ | 2024.02.12 | ์Šคํƒ | [๊ธฐ๋Šฅ๊ฐœ๋ฐœ](https://school.programmers.co.kr/learn/courses/30/lessons/42586) | [#2](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/2) |
| 2์ฐจ์‹œ | 2024.02.15 | ํ | [ํ”„๋กœ์„ธ์Šค](https://school.programmers.co.kr/learn/courses/30/lessons/42587) | [#6](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/6) |
| 3์ฐจ์‹œ | 2024.02.15 | ํž™ | [์•ผ๊ทผ์ง€์ˆ˜](https://school.programmers.co.kr/learn/courses/30/lessons/12927) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/10) |
| 4์ฐจ์‹œ | 2024.02.15 | ํž™ | [๊ตฌ๋ช…๋ณดํŠธ](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/14) |
| 5์ฐจ์‹œ | 2024.02.15 | ํž™ | [๋ชจ์Œ์‚ฌ์ „](https://school.programmers.co.kr/learn/courses/30/lessons/84512) | [#19](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/19) |
---
| 3์ฐจ์‹œ | 2024.02.18 | ํž™ | [์•ผ๊ทผ์ง€์ˆ˜](https://school.programmers.co.kr/learn/courses/30/lessons/12927) | [#10](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/10) |
| 4์ฐจ์‹œ | 2024.02.21 | ํ | [๊ตฌ๋ช…๋ณดํŠธ](https://school.programmers.co.kr/learn/courses/30/lessons/42885) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/14) |
| 5์ฐจ์‹œ | 2024.02.24 | DFS | [๋ชจ์Œ์‚ฌ์ „](https://school.programmers.co.kr/learn/courses/30/lessons/84512) | [#19](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/19) |
| 6์ฐจ์‹œ | 2024.02.27 | ์Šคํƒ | [๊ด„ํ˜ธ ํšŒ์ „ํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/76502) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/22) |
| 7์ฐจ์‹œ | 2024.03.01 | ๊ตฌํ˜„ | [์บ์‹œ](https://school.programmers.co.kr/learn/courses/30/lessons/17680) | [#24](https://github.com/AlgoLeadMe/AlgoLeadMe-7/pull/24) |
---
25 changes: 25 additions & 0 deletions kjs254/๊ตฌํ˜„/์บ์‹œ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def solution(cacheSize, cities):
answer = 0
cities = [city.lower() for city in cities]
cache, cache_hit = [], []

for i,city in enumerate(cities):
if len(cache)<cacheSize and city not in cache:
cache.append(city)
cache_hit.append(i)
answer +=5

elif city in cache:
cache_hit[cache.index(city)] =i
answer +=1

elif cache:
idx = cache_hit.index(min(cache_hit))
cache[idx] = city
cache_hit[idx] = i
answer +=5

else:
answer+=5

return answer

0 comments on commit 3267c9c

Please sign in to comment.