Pregunta de entrevista de Cognizant

Based upon some basic algorithms