Pergunta de entrevista da empresa Tata Consultancy Services

a very basic programming problem