Skip to content

Commit 550239b

Browse files
committed
0922
1 parent e644d02 commit 550239b

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @param {number[][]} img1
3+
* @param {number[][]} img2
4+
* @return {number}
5+
*/
6+
var largestOverlap = function (img1, img2) {
7+
// 상하좌우로 움직일수있고,
8+
// 최대한 많이 겹칠때 1의 갯수를 구하라?
9+
// 9*9매트리스로 그릴려했으나, 움직이는 방향이 중간에 바뀌면 커버가 불가하다.
10+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @param {number[]} bills
3+
* @return {boolean}
4+
*/
5+
var lemonadeChange = function (bills) {
6+
const billCount = Array(5).fill(0);
7+
8+
for (const bill of bills) {
9+
let change = bill - 5;
10+
if (change !== 0) {
11+
for (let i = 4; i >= 0; i--) {
12+
if (billCount[i] === 0) continue;
13+
const curBil = i * 5;
14+
while (billCount[i] * curBil >= change) {}
15+
if (curBil >= change) {
16+
const total = curBil * billCount[i];
17+
if (total >= change) change === 0;
18+
else {
19+
change -= billCount[i] * curBil;
20+
billCount[i] = 0;
21+
}
22+
}
23+
if (change === 0) break;
24+
}
25+
if (change > 0) return false;
26+
}
27+
billCount[bill / 5]++;
28+
console.log(billCount);
29+
}
30+
return true;
31+
};

0 commit comments

Comments
 (0)