Skip to content

Commit 19e8f54

Browse files
committed
feat: add js solution to lc problem: No.0860
1 parent 5258841 commit 19e8f54

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

solution/0800-0899/0860.Lemonade Change/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,20 @@ const lemonadeChange = (bills: number[], f = 0, t = 0): boolean =>
314314
);
315315
```
316316

317+
#### JavaScript
318+
319+
```js
320+
const lemonadeChange = (bills, f = 0, t = 0) =>
321+
bills.every(
322+
x => (
323+
(!(x ^ 5) && ++f) ||
324+
(!(x ^ 10) && (--f, ++t)) ||
325+
(!(x ^ 20) && (t ? (f--, t--) : (f -= 3), 1)),
326+
f >= 0
327+
),
328+
);
329+
```
330+
317331
<!-- tabs:end -->
318332

319333
<!-- solution:end -->

solution/0800-0899/0860.Lemonade Change/README_EN.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,20 @@ const lemonadeChange = (bills: number[], f = 0, t = 0): boolean =>
299299
);
300300
```
301301

302+
#### JavaScript
303+
304+
```js
305+
const lemonadeChange = (bills, f = 0, t = 0) =>
306+
bills.every(
307+
x => (
308+
(!(x ^ 5) && ++f) ||
309+
(!(x ^ 10) && (--f, ++t)) ||
310+
(!(x ^ 20) && (t ? (f--, t--) : (f -= 3), 1)),
311+
f >= 0
312+
),
313+
);
314+
```
315+
302316
<!-- tabs:end -->
303317

304318
<!-- solution:end -->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const lemonadeChange = (bills, f = 0, t = 0) =>
2+
bills.every(
3+
x => (
4+
(!(x ^ 5) && ++f) ||
5+
(!(x ^ 10) && (--f, ++t)) ||
6+
(!(x ^ 20) && (t ? (f--, t--) : (f -= 3), 1)),
7+
f >= 0
8+
),
9+
);

0 commit comments

Comments
 (0)