题解 | #小猪摘水果#
小猪摘水果
https://www.nowcoder.com/practice/fdb76b9170dc4e689a7eceee97159d96
import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param fruit int整型一维数组
* @return int整型
*/
public int mostFruitTree (int[] fruit) {
// write code here
int fast=10;
int max=fast;
for(int i=0;i<fruit.length;i++){
fast=fast+fruit[i];
if(fast>max) max=fast;
}
return max;
}
}
基恩士成长空间 440人发布