zoukankan      html  css  js  c++  java
  • 爱奇艺笔试

    //爱奇艺笔试0913
    // 三数之和
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        Set<String> set = new HashSet<>();
        while(sc.hasNext()) {
            int temp = sc.nextInt();
            list.add(temp);
    
        }
        int n = list.size();
        Collections.sort(list);
        for(int i=0; i < n; i++) {
            for(int j=i+1; j < n; j++) {
                for(int k=j+1; k < n; k++) {
                    int a = list.get(i), b = list.get(j), c = list.get(k);
                    if(a+b+c == 0) {
                        String str = a + " " + b +" " + c;
                        if(!set.contains(str)) {
                            System.out.println(str);
                            set.add(str);
                        }
                    }
                }
            }
        }
    }
    
    
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        while(sc.hasNext()) {
            int temp = sc.nextInt();
            list.add(temp);
        }
        int n = list.size();
        int count = 1, num = list.get(0);
        for(int i=1; i < n; i++) {
            int t = list.get(i);
            if(t == num) count++;
            else {
                if(count > 1) count --;
                else {
                    count = 1;
                    num = t;
                }
            }
        }
        System.out.println(num);
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        int n = s.length;
        int[] cnt = new int[256];
        int res = 0;
        for(int i=0, j=0; j < n; j++) {
            int t = s[j] - 'a';
            cnt[t]++;
            if(cnt[t] > 1) {
                cnt[t] = 1;
                i ++;
                //System.out.println("i "+ j);
            }
            res = Math.max(res, j-i+1);
        }
        System.out.println(res);
    }
    
    
  • 相关阅读:
    【C/C++】动态内存分配和链表
    【C/C++】递归算法
    UnicodeMath编码教程
    UnicodeMath数学公式编码_翻译(Unicode Nearly Plain
    浅谈Java反射机制
    lvs--小白博客
    python部署lvs
    python部署galery集群
    python第九章:面向对象--小白博客
    python之yagmail模块--小白博客
  • 原文地址:https://www.cnblogs.com/lixyuan/p/13663469.html
Copyright © 2011-2022 走看看