UKG interview question

Leetcode regarding arrays + strings