VinBrain interview question

HackerRank: Algorithm - Data Structure