Pergunta de entrevista da empresa Microsoft

Leetcode easy type of problem. Think I used a hashmap to solve