Pregunta de entrevista de HighRadius

Coding question in cpp or in java.