Pregunta de entrevista de Tencent

Algorithm question question (I almost forgot it)