Starting in the top left corner of a 2*2 grid, there are 6 routes (without backtracking) to the bottom right corner.

How many routes are there through a 20*20 grid?
我的思路是从左上角的顶点开始压栈,每个点弹出来后将其相邻的点的值(右边和下边两点)+1,如果这两点(也有可能只有一点,如果被处理的点位于边框上)的值为0则压栈。然后返回grid[20][20]就ok了。小心整数溢出!
更强的解法是直接用阶乘,20!还没有理解为什么。
我的代码如下: