We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 7462b7b + e537290 commit b97489cCopy full SHA for b97489c
live6/test64/문제3/이지은.js
@@ -0,0 +1,44 @@
1
+function solution(cacheSize, cities) {
2
+ var answer = 0;
3
+ cities = cities.map((el) => el.toLowerCase());
4
+
5
+ let arr = new Map();
6
7
+ for (let i = 0; i < cities.length; i++) {
8
+ if (cities.length < 3) {
9
+ if (!arr.has(cities[i])) {
10
+ arr.set(cities[i]);
11
+ answer += 5;
12
+ } else {
13
+ answer++;
14
+ }
15
16
+ if (arr.has(cities[i])) {
17
18
19
+ const firstKey = arr.keys().next().value;
20
+ arr.delete(firstKey);
21
22
23
24
25
26
27
28
+ return answer;
29
+}
30
31
+console.log(
32
+ solution(3, [
33
+ 'Jeju',
34
+ 'Pangyo',
35
+ 'Seoul',
36
+ 'NewYork',
37
+ 'LA',
38
39
40
41
42
43
+ ])
44
+);
0 commit comments