題目
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
How many possible unique paths are there?
Above is a 3 x 7 grid. How many pZ喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vc3NpYmxlIHVuaXF1ZSBwYXRocyBhcmUgdGhlcmU/PC9wPgo8cD4KTm90ZTogbSBhbmQgbiB3aWxsIGJlIGF0IG1vc3QgMTAwLjwvcD4KPHN0cm9uZz631s72PC9zdHJvbmc+CjxwPtK71tbLvMK3vs3Kx7avzKy55ruuo6zB7dK71ta+zcrHx/PX6brPyv1DKG4mIzQzO20tMiwgbS0xKaOsx/PX6brPyv27ubXD0KHQxNLns/aho9XiwO+4+LP2tcTKx7avzKy55ruutcS94reooaM8L3A+CjxwPjxzdHJvbmc+tPrC6zwvc3Ryb25nPjwvcD4KPHA+PHByZSBjbGFzcz0="brush:java;">public class UniquePaths { public int uniquePaths(int m, int n) { int[] dp = new int[n]; // init dp[0] = 1; // dp for (int i = 0; i < m; ++i) { for (int j = 1; j < n; ++j) { dp[j] += dp[j - 1]; } } return dp[n - 1]; } }