Skip to content

Commit 411cb8c

Browse files
committed
69차 3번 제출
1 parent d24c428 commit 411cb8c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

live6/test69/문제3/이지은.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
function solution(want, number, discount) {
2+
var answer = 0;
3+
4+
let 기준 = new Map();
5+
for (let k = 0; k < want.length; k++) {
6+
기준.set(want[k], number[k]);
7+
}
8+
9+
for (let i = 0; i <= discount.length - 10; i++) {
10+
let arr = discount.slice(i, i + 10);
11+
// console.log(i);
12+
13+
let map1 = new Map();
14+
for (let x of arr) {
15+
map1.set(x, (map1.get(x) ? map1.get(x) : 0) + 1);
16+
}
17+
18+
//비교
19+
let isValid = true;
20+
for (const [fruit, num] of 기준) {
21+
if ((map1.get(fruit) || 0) < num) {
22+
isValid = false;
23+
break;
24+
}
25+
}
26+
27+
if (isValid) answer++;
28+
}
29+
30+
return answer;
31+
}
32+
console.log(
33+
solution(
34+
['banana', 'apple', 'rice', 'pork', 'pot'],
35+
[3, 2, 2, 2, 1],
36+
[
37+
'chicken',
38+
'apple',
39+
'apple',
40+
'banana',
41+
'rice',
42+
'apple',
43+
'pork',
44+
'banana',
45+
'pork',
46+
'rice',
47+
'pot',
48+
'banana',
49+
'apple',
50+
'banana',
51+
]
52+
)
53+
);

0 commit comments

Comments
 (0)