Crunchyroll interview question

Asked to solve leetcode style garbage