直接在原矩阵上操作即可 alt

int minPathSum(int** matrix, int matrixRowLen, int* matrixColLen ) {
    for(int i=0;i<matrixRowLen;i++){
        for(int j=0;j<*matrixColLen;j++){
            if(i==0&&j!=0){
                matrix[i][j]=matrix[i][j-1]+matrix[i][j];
            }else if(j==0&&i!=0){
                matrix[i][j]=matrix[i-1][j]+matrix[i][j];
            }else if(i==0&&j==0){
                matrix[i][j]=matrix[i][j];
            }
            else{
                matrix[i][j]=(matrix[i][j-1]+matrix[i][j])>(matrix[i-1][j]+matrix[i][j])?matrix[i-1][j]+matrix[i][j]:matrix[i][j-1]+matrix[i][j];
            }
        }
    }
    return matrix[matrixRowLen-1][(*matrixColLen)-1];
}