Skip to content

Commit e4c3cfe

Browse files
committed
Mar 16
1 parent 6b18821 commit e4c3cfe

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution:
2+
def repairCars(self, ranks: list[int], cars: int) -> int:
3+
left, right = 1, cars * cars * ranks[0]
4+
while left < right:
5+
mid = (left + right) // 2
6+
repaired = sum(int((mid / rank) ** 0.5) for rank in ranks)
7+
if repaired >= cars:
8+
right = mid
9+
else:
10+
left = mid + 1
11+
return left
12+
13+
14+
def main():
15+
ranks = [4, 2, 3, 1]
16+
cars = 10
17+
assert Solution().repairCars(ranks, cars) == 16
18+
19+
ranks = [5, 1, 8]
20+
cars = 6
21+
assert Solution().repairCars(ranks, cars) == 16
22+
23+
24+
if __name__ == '__main__':
25+
main()

2025-03-March-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
| March 13 | [https://leetcode.com/problems/zero-array-transformation-ii/](https://leetcode.com/problems/zero-array-transformation-ii/) | Medium | Unsolved |
2020
| March 14 | [2226. Maximum Candies Allocated to K Children](https://leetcode.com/problems/maximum-candies-allocated-to-k-children/) | Medium | Solved |
2121
| March 15 | [2560. House Robber IV](https://leetcode.com/problems/house-robber-iv/) | Medium | Unsolved |
22-
| March 16 | []() | | |
22+
| March 16 | [2594. Minimum Time to Repair Cars](https://leetcode.com/problems/minimum-time-to-repair-cars/) | Medium | Unsolved |
2323
| March 17 | []() | | |
2424
| March 18 | []() | | |
2525
| March 19 | []() | | |
@@ -41,5 +41,5 @@
4141
| Level | Problems | Solved | Unsolved |
4242
| --- | --- | --- | --- |
4343
| Easy | 5 | 5 | 0 |
44-
| Medium | 10 | 5 | 5 |
44+
| Medium | 11 | 5 | 6 |
4545
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)