Citadel Interview Question

Leetcode hard question related to backtracking