Skip to content

Commit 3c7e464

Browse files
authored
Create 1564-put-boxes-into-the-warehouse-i.js
1 parent 25485ec commit 3c7e464

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {number[]} boxes
3+
* @param {number[]} warehouse
4+
* @return {number}
5+
*/
6+
const maxBoxesInWarehouse = function(boxes, warehouse) {
7+
boxes.sort((a, b) => a - b)
8+
const m = boxes.length, n = warehouse.length
9+
let i = 0, j = 0
10+
for(; i < m && j < n; i++) {
11+
if(boxes[m - i - 1] <= warehouse[j]) {
12+
j++
13+
}
14+
}
15+
return j
16+
};

0 commit comments

Comments
 (0)