We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e48df67 commit 7f1a0d8Copy full SHA for 7f1a0d8
1 file changed
lkhyun/202510/22 PGM Lv2 [1차]캐시.md
@@ -0,0 +1,25 @@
1
+```java
2
+import java.util.*;
3
+class Solution {
4
+ public int solution(int cacheSize, String[] cities) {
5
+ int answer = 0;
6
+ List<String> cache = new LinkedList<>();
7
+
8
+ for(String c : cities){
9
+ String city = c.toLowerCase();
10
+ if(cache.contains(city)){
11
+ cache.remove(city);
12
+ cache.add(city);
13
+ answer++;
14
+ }else{
15
16
+ answer+=5;
17
+ }
18
+ if(cache.size() > cacheSize){
19
+ cache.remove(0);
20
21
22
+ return answer;
23
24
+}
25
+```
0 commit comments