Pregunta de entrevista de Wayfair

the code question are similar to leetcode