Canva interview question

A back-tracking algorithm problem, medium difficulty on LeetCode