Fractional knapsack

medium

Because items can be split, there is never a reason to leave a denser item partly untaken. Forbid splitting and the same algorithm becomes wrong - which is exactly why 0/1 knapsack needs DP.

Worst O(n log n)Space O(1)
Loading the fractional knapsack engine…

Where to go next