Roblox interview question

Leetcode hard backtracking/dynamic programming problem