Skip to content

Commit 362cca7

Browse files
authored
Create 2335-minimum-amount-of-time-to-fill-cups.js
1 parent dcd4c70 commit 362cca7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @param {number[]} amount
3+
* @return {number}
4+
*/
5+
const fillCups = function(amount) {
6+
amount.sort((a, b) => a- b)
7+
let res = 0;
8+
while (amount[2] !== 0) {
9+
res++;
10+
amount[2]--;
11+
if (amount[1] > 0) {
12+
amount[1]--;
13+
}
14+
amount.sort((a, b) => a- b)
15+
}
16+
return res;
17+
};

0 commit comments

Comments
 (0)