HackerEarth interview question

A problem on Data Structure