Back to course home
0% completed
Vote For New Content
Questions
Jimmy
Sep 10, 2024
- Why are we sorting the capacities in ascending order and then iterating from the end? Why don't we just sort the capacities in descending order and iterate from the start? Seems simpler and less convoluted.
- Why is the space complexity O(n)? Shouldn't the space be O(m) since we are sorting the capacity (and not the apple) array?
0
0
Comments
Comments
Run Qi Jack Lia year ago
Good question. I think the same for your first and second point.
-
Sorting the capacity array in descending order is more intuitive to understand.
-
should be O(m) because we are sorting the capacity of the boxes, not the apples.