Pergunta de entrevista da empresa TD

Please solve this question about a problem they are currently facing