Pregunta de entrevista de Meta

It was a LeetCode medium problem