Pregunta de entrevista de Microsoft

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