思路:使用Java自带BitSet函数
public class Main {
public static void main(String[] args) {
BitSet bitSet = new BitSet();
Map<Integer,BitSet> map=new HashMap<>();
long[] phone={15522222222L,15533333333L,15544444444L,15522222222L};
BitSet bitSet155 =map.computeIfAbsent(155,k->bitSet);
// int num0= (int) (num/100000000);
// System.out.println("前三位:"+num0);
// int num1= (int) (num%100000000);
// System.out.println(num1);
for(int i=0;i<phone.length;i++){
//int num0=(int) (phone[0]/100000000);
int num1=(int) (phone[i]%100000000);
bitSet155.set(num1);
}
for(int i=0;i<999999999;i++){
if(bitSet155.get(i)){
System.out.println("155"+i);
}
}
}
}
截图: