所谓的BitMap就是用一个bit位来标记某个元素所对应的value,而key即是该元素,由于BitMap使用了bit位来存储数据,因此可以大大节省存储空间. public class Test { //为了方便,假设数据是以数组的形式给我们的 public static Set<Integer> test(int[] arr) { //用来把重复的数返回,存在Set里,这样避免返回重复的数. Set<Integer> output = new HashSet<>();…
int a[] = {1,3}; int b[] = {1,3,5}; int size = a.length>b.length ?a.length:b.length; int valueA =0 ; int valueB =0; for(int i =0;i<size;i++){ int tempA =1; int tempB =1; if(i<a.length){ valueA += tempA << a[i]; valueB += tempB << b[i]…
题目 Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,104 ]. The first one who bets on a unique number wins. For example, if there ar…