Sponsored
Use these hints if you're stuck. Try solving on your own first.
It's optimal to finish the apples that will rot first before those that will rot last
You need a structure to keep the apples sorted by their finish time
Solve with full IDE support and test cases