1 Star 1 Fork 0

laodasbch/Leetcode-Complete-Guide

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
b13.txt 615 Bytes
Copy Edit Raw Blame History
junbinLiang authored 5 years ago . move
思路:
robot path 的经典dp 解法
代码:
import java.util.*;
class Solution {
public int solve(int[][] grid) {
// Write your code here
for(int i=1;i<grid.length;i++){
grid[i][0]+=grid[i-1][0];
}
for(int i=1;i<grid[0].length;i++){
grid[0][i]+=grid[0][i-1];
}
for(int i=1;i<grid.length;i++){
for(int j=1;j<grid[0].length;j++){
grid[i][j]+=Math.max(grid[i-1][j],grid[i][j-1]);
}
}
return grid[grid.length-1][grid[0].length-1];
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/laodasbch/Leetcode-Complete-Guide.git
git@gitee.com:laodasbch/Leetcode-Complete-Guide.git
laodasbch
Leetcode-Complete-Guide
Leetcode-Complete-Guide
master

Search