Frage im Vorstellungsgespräch bei Canva

A back-tracking algorithm problem, medium difficulty on LeetCode