TikTok Interview Question

two pointers and backtracking lc qs