22

糖果分配

http://www.nowcoder.com/questionTerminal/c0e676f4cf9846c785ade34d9472951b

import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int[]child = strToArray(sc.nextLine().split(" "));
        int[]candy = strToArray(sc.nextLine().split(" "));
        int i=0,j=0,cnt=0;
        while(i<child.length && j<candy.length) {
            if(child[i]<=candy[j]) {
                ++i;
                ++cnt;
            }
            ++j;
        }
        System.out.println(cnt);

    }

    public static int max(int... a) {
        return Arrays.stream(a).max().getAsInt();
    }
    public static int[] strToArray(String[] a) {
        int[]p = Arrays.stream(a).mapToInt(Integer::valueOf).toArray();
        return p;
    }

}
全部评论

相关推荐

给我发了笔试链接,想着等晚上回去做,结果还没做流程就终止了
伟大的小黄鸭在学习:我猜就是笔试几乎没用,就是用来给用人部门拖时间复筛简历的,可能用人部门筛到你简历觉得不合适就提前挂了
点赞 评论 收藏
分享
人力小鱼姐:实习经历没有什么含金量,咖啡店员迎宾这种就别写了,其他两段包装一下 想找人力相关的话,总结一下个人优势,结合校园经历里有相关性的部分,加一段自我评价
点赞 评论 收藏
分享
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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