UKG interview question

Hackerrank task, puzzle & arrays