Buzzvil interview question

general data structure question and explain the thought process (+ what is the time complexity for your solution)