Wise interview question

OOP/data structures problem in HackerRank