Pergunta de entrevista da empresa Tarento

Asked to explain the answer for a coding qn