Pregunta de entrevista de Google

A common problem from leetcode/CC150/any algorithm book.