We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 63da7b4 commit 026a1dcCopy full SHA for 026a1dc
solution/1700-1799/1710.Maximum Units on a Truck/Solution.ts
@@ -1,10 +1,12 @@
1
-export function maximumUnits(boxTypes: number[][], truckSize: number): number {
+function maximumUnits(boxTypes: number[][], truckSize: number): number {
2
boxTypes.sort(([_, a], [__, b]) => b - a);
3
let ans = 0;
4
for (const [count, size] of boxTypes) {
5
ans += Math.min(truckSize, count) * size;
6
truckSize -= count;
7
- if (truckSize < 0) break;
+ if (truckSize < 0) {
8
+ break;
9
+ }
10
}
11
return ans;
12
0 commit comments