TikTok interview question

Build react component, algorithm solving