Algorithms, Dynamic Programming, Data Structures, Computer Science, Leetcode.
tree is large, some branches are not shown, but this does not affect the understanding of dynamic programming. The red font indicates which face value to choose. We can see that the function toy(3) is called twice in this image. If we store the value of toy(3), we can reuse the old stored value