题解 | #年终奖#

年终奖

http://www.nowcoder.com/practice/72a99e28381a407991f2c96d8cb238ab

import java.util.*;

public class Bonus { public int getMost(int[][] board) { int row = board.length; int col = board[0].length; int[][] bonus = new int[row +1][col + 1]; bonus[1][1] = board[0][0]; for(int i = 2;i <= col;i++ ){ bonus[1][i] = bonus[1][i-1]+board[0][i-1]; } for(int i = 2;i <= row;i++ ){ bonus[i][1] = bonus[i-1][1]+board[i-1][0]; } for(int i = 2;i <= row;i ++){ for(int j = 2;j <= col;j++){ bonus[i][j] = Math.max(bonus[i-1][j],bonus[i][j-1]) + board[i-1][j -1]; } } return bonus[row][col];

}

}

全部评论
你这写了尼玛个gou字 ,不想好好写,就别写
点赞 回复 分享
发布于 2022-07-23 17:06

相关推荐

10-28 10:48
已编辑
门头沟学院 Java
孩子我想要offer:发笔试后还没笔试把我挂了,然后邮箱一直让我测评没测,后面不知道干嘛又给我捞起来下轮笔试,做完测评笔试又挂了😅
点赞 评论 收藏
分享
用微笑面对困难:你出于礼貌叫了人一声大姐,大姐很欣慰,她真把你当老弟
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务