Pregunta de entrevista de Cognizant

Gave to write a code