This problem combines tries with backtracking on a grid — two fundamental techniques. It tests your ability to optimize a brute-force approach using the right data structure.
Enable JavaScript for the full StreamPrep guide.