Pergunta de entrevista da empresa Google

Basic stack question with a followup