TikTok interview question

How to implement a algorithm