TikTok Interview Question

How to implement a algorithm