Question d’entretien chez Rakuten

Basic string repetition question and it's optimisation.