JasonChang

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

recursion programming

 1 public class Solution {
 2     public int uniquePaths(int m, int n) {
 3         // IMPORTANT: Please reset any member data you declared, as
 4         // the same Solution instance will be reused for each test case.
 5         int[][] result = new int[m+1][n+1];
 6         result[1][1] = 1;
 7         for(int i = 1; i < m+1; i++)
 8             for(int j = 1; j < n+1; j++){
 9                 result[i][j] += result[i-1][j] + result[i][j-1]; 
10             }
11         return result[m][n];
12     }
13 }

 

 

posted on 2013-11-05 16:24  JasonChang  阅读(163)  评论(0编辑  收藏  举报