现在有一个的格子,第行第列的格子有个胡萝卜。 现在米兔要从左上角的格子走到右下角的格子,来收集这些胡萝卜。并且每次只能向右或者向下走。 请计算米兔能够收集到的最大胡萝卜数量。
示例1
输入
[[0,1],[1,1]]
输出
2
说明
先向右走再向下走
示例2
输入
[[1,4,9],[3,5,9]]
输出
23
说明
向右走2步再向下走1步
加载中...
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型二维数组 * @return int整型 */ public int maxPathSum (int[][] a) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型vector
> * @return int整型 */ int maxPathSum(vector
>& a) { // write code here } };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param a int整型二维数组 # @return int整型 # class Solution: def maxPathSum(self , a ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型二维数组 * @return int整型 */ public int maxPathSum (List
> a) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型二维数组 * @return int整型 */ function maxPathSum( a ) { // write code here } module.exports = { maxPathSum : maxPathSum };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param a int整型二维数组 # @return int整型 # class Solution: def maxPathSum(self , a ): # write code here
package main /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型二维数组 * @return int整型 */ func maxPathSum( a [][]int ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型二维数组 * @param aRowLen int a数组行数 * @param aColLen int* a数组列数 * @return int整型 */ int maxPathSum(int** a, int aRowLen, int* aColLen ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param a int整型二维数组 # @return int整型 # class Solution def maxPathSum(a) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型二维数组 * @return int整型 */ def maxPathSum(a: Array[Array[Int]]): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型二维数组 * @return int整型 */ fun maxPathSum(a: Array
): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型二维数组 * @return int整型 */ public int maxPathSum (int[][] a) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型二维数组 * @return int整型 */ export function maxPathSum(a: number[][]): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型二维数组 * @return int整型 */ func maxPathSum ( _ a: [[Int]]) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型二维数组 * @return int整型 */ pub fn maxPathSum(&self, a: Vec
>) -> i32 { // write code here } }
[[0,1],[1,1]]
2
[[1,4,9],[3,5,9]]
23