Pergunta de entrevista da empresa Bloomberg

They asked me to solve a medium-level algorithmic problem from Hackerank involving data structures, and then explain my approach clearly while optimizing for both time and space complexity.