TikTok interview question

Common data structure base code.