题解 | #牛奶工厂#

牛奶工厂

https://www.nowcoder.com/practice/264efc6e41394a0286c51eb2521ba386

知识点:双指针

思路:双指针遍历即可,入门题,当然也有时间复杂度更快的 做法

编程语言:java

import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param time1 int整型一维数组
     * @param time2 int整型一维数组
     * @param m int整型
     * @param n int整型
     * @return int整型
     */
    public int milk_sum (int[] time1, int[] time2, int m, int n) {
        int count = 0;
        for (int i = 0; i < m; i++) {
            count += time1[i];
        }
        for (int i = 0; i < n; i++) {
            count += time2[i];
        }
        return count;
    }
}

全部评论

相关推荐

怎么起名字:早知道就不读书了,害得我送外卖还得扶眼镜
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-08 13:15
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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