每日训练_day11

 day11_0506

选择题

 1.ArrayList是实现了基于动态数组的数据结构,LinkedList基于链表的数据结构。

ArrayList是基于数组实现的,所以查询快,增删慢;LinkedList是基于链表实现的,所以查找慢,增删快。

  • key:是要保存到 Map 集合中的键名。
  • value:是要保存到 Map 集合中对应键名的键值对象。

 

 这种是默认创建大小为10的数组,每次扩容大小为1.5倍
ArrayList list=new ArrayList(20);
使用的ArrayList的有参构造函数,直接扩容,所以为零次

PreparedStatement从Statement继承而来

 CallableStatement从PreparedStatement继承而来

Statement是爷爷,PreparedStatement是爸爸, CallableStatement是孙子

编程 

最近公共祖先

public class LCA {
    public static void main(String[] args) {
        System.out.println(getLCA(2,3));
    }
    public static int getLCA(int a, int b) {
    while(a!=b){
        if(a<b){
         b=b/2;
        }else {
         a=a/2;
        }
    }
    return a;
    }
}
求最大连续bit数

public class BitCount {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        System.out.println(Bit(n));
    }

    private static int  Bit(int n) {
        String str=Integer.toBinaryString(n);
        char[] c=str.toCharArray();
        int count=0;
        int max=0;
        for (int i = 0; i < c.length; i++) {
            if (c[i]=='1'){
                count++;
            }else {
                max=Math.max(max,count);
                count=0;
            }
        }
        max=Math.max(count,max);
        return max;
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值