Skip to content

Commit c5cbab8

Browse files
BarklimBarklim
Barklim
authored and
Barklim
committed
Create 2594.js
1 parent 0276071 commit c5cbab8

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

example/Dayly/2594.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @param {number[]} ranks
3+
* @param {number} cars
4+
* @return {number}
5+
*/
6+
var repairCars = function(ranks, cars) {
7+
8+
};
9+
10+
const example1 = repairCars([4,2,3,1], 10); // 16
11+
const example2 = repairCars([5,1,8], 6); // 16
12+
13+
console.log(example1);
14+
console.log(example2);
15+
16+
// var repairCars = function(ranks, cars) {
17+
// let left = 1
18+
// let right = Math.max(...ranks)*cars*cars
19+
20+
// var canRepairAll = function(time) {
21+
// let totalCarsRepaired = 0
22+
// for (let rank of ranks) {
23+
// totalCarsRepaired += Math.floor(Math.sqrt(time/rank))
24+
// if (totalCarsRepaired >= cars) return true
25+
// }
26+
// return false
27+
// }
28+
29+
// while (left < right) {
30+
// let mid = Math.floor((left + right)/2)
31+
32+
// if (canRepairAll(mid)) {
33+
// right = mid
34+
// } else {
35+
// left = mid + 1
36+
// }
37+
// }
38+
39+
// return left
40+
// };

0 commit comments

Comments
 (0)