Pregunta de entrevista de Microsoft

Leetcode problems so make you practice. Also, explain your reasoning behind it.