Pergunta de entrevista da empresa Cognizant

Coding challenge was given to be solved.