Pergunta de entrevista da empresa ByteDance

Is there a faster way to implement this solution?