题解 | #小猪摘水果#
小猪摘水果
https://www.nowcoder.com/practice/fdb76b9170dc4e689a7eceee97159d96
package main
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param fruit int整型一维数组
* @return int整型
*/
func mostFruitTree( fruit []int ) int {
// write code here
if len(fruit)==0{
return 10
}
num :=10
max :=num
for _,val :=range fruit{
num=num+val
if num>max{
max =num
}
}
return max
}
