Pregunta de entrevista de Cyient

Given a logical problem to solve through coding