TikTok interview question

some array related manipulation question I forgot