一、选择题总计20道408内容+大数据相关有单选,也有多选二、编程题两道很简单,第一次笔试AK第一题:随机播放器直接用queue搞定import java.util.LinkedList;import java.util.Queue;import java.util.Scanner;public class Main {    public static void main(String[] args) {        Scanner sc = new Scanner(System.in);        int n = sc.nextInt();        Queue<Long> queue1 = new LinkedList<> ();        for(int i=1;i<=n;i++){            queue1.offer(sc.nextLong());        }        while (queue1.size()!=0){            //先出一个 并删除            System.out.print(queue1.poll());            System.out.print(' ');            queue1.offer(queue1.peek());            queue1.poll();        }    }}第二题:挑选要求按右筛选去重,我直接反转去重再反转,全都调用的APIimport java.util.*;public class Main {    public static void main(String[] args) {        Scanner sc = new Scanner(System.in);        int n = sc.nextInt();        ArrayList<Integer> arr = new ArrayList<Integer>();        for(int i=1;i<=n;i++){            arr.add(sc.nextInt());        }        //反转        Collections.reverse(arr);        //去重 不排序        LinkedHashSet<Integer> set = new LinkedHashSet<Integer>(arr);        ArrayList<Integer> ans = new ArrayList<Integer>(set);        //再反转        Collections.reverse(ans);        for(int i=0;i<ans.size();i++){            System.out.print(ans.get(i));            System.out.print(' ');        }    }}
点赞 7
评论 3
全部评论

相关推荐

头像
05-14 12:29
安卓
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务