TikTok interview question

Algorithm problems. Heap; dynamic programming.