zoukankan      html  css  js  c++  java
  • leetcode 63 简单题

    题目很水。。。

    直接放代码了

    int uniquePathsWithObstacles(int** obstacleGrid, int obstacleGridRowSize, int obstacleGridColSize) {
        int path[obstacleGridRowSize][obstacleGridColSize];
        if(obstacleGrid[0][0]==1)
            path[0][0] = 0;
        else
            path[0][0] = 1;
        for(int i =1;i<obstacleGridRowSize;i++)
            if(obstacleGrid[i][0]==0&&path[i-1][0]==1)
                path[i][0] = 1;
            else
                path[i][0] = 0;
        for(int i =1;i<obstacleGridColSize;i++)
            if(obstacleGrid[0][i]==0&&path[0][i-1]==1)
                path[0][i] = 1;
            else
                path[0][i] = 0;
        for(int i =1;i<obstacleGridRowSize;i++)
            for(int j =1;j<obstacleGridColSize;j++)
            {
                if(obstacleGrid[i][j]==0)
                    path[i][j] = path[i-1][j]+path[i][j-1];
                else
                    path[i][j] = 0;
            }
        return path[obstacleGridRowSize-1][obstacleGridColSize-1];
    }
  • 相关阅读:
    sys模块
    反射
    动态导入模块
    类的静态属性
    多态
    继承
    组合
    linux系统各个子目录的内容
    mysql安装
    Docker 数据卷操作
  • 原文地址:https://www.cnblogs.com/jzcbest1016/p/9013294.html
Copyright © 2011-2022 走看看