Pergunta de entrevista da empresa Fuse (Canada)

How would you solve problem in linear time