When items can be cut (grain, fabric, time), sort them by value per kg and pour the best in first. Only the last item ever needs cutting, to fill the leftover space exactly.
- Average time
- O(n log n)
- Space
- O(1)
When items can be cut (grain, fabric, time), sort them by value per kg and pour the best in first. Only the last item ever needs cutting, to fill the leftover space exactly.