首页 > 其他 > 详细

Unique Paths II

时间:2015-04-15 07:11:24      阅读:95      评论:0      收藏:0      [点我收藏+]
public class Solution {
    public int uniquePathsWithObstacles(int[][] obstacleGrid) {
         if(obstacleGrid == null || obstacleGrid.length==0 || obstacleGrid[0].length==0)  return 0;
 
    int[] res= new int[ obstacleGrid[0].length];
    res[0]=1;
    for(int i=0; i< obstacleGrid.length; i++){
        for(int j=0; j< obstacleGrid[0].length;j++){
            if(obstacleGrid[i][j]==1){
                res[j]=0;
            }else{ 
                if(j>0)
                    res[j] += res[j-1];
            }
            
        }
    }
    return res[ obstacleGrid[0].length-1];
    
    }
}

ref http://blog.csdn.net/linhuanmars/article/details/22135231

Unique Paths II

原文:http://www.cnblogs.com/jiajiaxingxing/p/4427474.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!