LC: 1196. How Many Apples Can You Put into the Basket - spiralgo/algorithms GitHub Wiki
1196. How Many Apples Can You Put into the Basket:
The Essence:
We have to focus on these two keys:
- Maximum number of apples
- Up to 5000 units of weight. (Which is a limit or restriction.)
These keys indicate that we will need a greedy approach.
It means we will start with the lightest apple to gain the maximum number of apples.
Details:
The apple array is not sorted. We can either use a min-heap implementation (like PQ) or a built-in sort function like Arrays.sort.