TikTok interview question

Algorithm, data structures, Leetcode question