Pregunta de entrevista de Oracle

Basic computer programming question and asked to solve hackerrank problem