When solving this problem, we must first observe how word1 becomes word2. Taking Example1 as an example, the lower left figure lists the distance from “horse” to “ros”.
Binary search tree (BST) is a binary tree. It provides some useful operations including search, insert, delete, minimum, maximum, successor and predecessor.
This problem asks us to calculate the total number of all possible paths from the top-left corner to the bottom-right corner. We can observe that to go from the top-left corner to the bottom-right corner, the robot can only go right or down.
This problem asks us to list all possible combinations, so we can use backtracking to find them. However, we must avoid finding duplicated combinations.