Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
There can only be three scenarios for deletions such that both minimum and maximum elements are removed:
Scenario 1: Both elements are removed by only deleting from the front.
Scenario 2: Both elements are removed by only deleting from the back.
Scenario 3: Delete from the front to remove one of the elements, and delete from the back to remove the other element.
Compare which of the three scenarios results in the minimum number of moves.