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);
    }
    
    
  • 相关阅读:
    把Outlook与Google Calendar同步了
    (int) Int32.Parse() Convert.toInt32() (转)
    Http Context(转)
    DataReader DataSet(转)
    主键和外键(转)
    显卡参数学习
    开源抽象工厂模式,序列化,反序列化等..
    ASP.NET中App_Code,App_Data等文件夹的作用(转)
    using tianjiayinyong qubie
    xuliehua fanxuliehua xml(zhuan)
  • 原文地址:https://www.cnblogs.com/lixyuan/p/13663469.html
Copyright © 2011-2022 走看看