Pregunta de entrevista de MBC Group

A problem solving question in javascript.