Pergunta de entrevista da empresa Agoda

Solve a coding problem using a HashSet or Dictionary and explain the time complexity.