Question d’entretien chez Oracle

Basic computer programming question and asked to solve hackerrank problem