TikTok interview question

A backtracking question and ML knowledge