Collecting_apples

How to solve Collecting Apples | Practice Problems question on HackerEarth?