HackerEarth Interview Question

A problem on Data Structure