当前位置:网站首页>Judge the same value of two sets 𞓜 different values
Judge the same value of two sets 𞓜 different values
2022-06-26 03:54:00 【Strong wind blows】
Take the same value
// 1 Data one
List<Integer> ces1 = Arrays.asList(2, 3, 454, 5, 3);
// 2 Data two
List<Integer> ces2 = Arrays.asList(2, 3, 43, 5, 32, 12);
// Store results
List list=new ArrayList();
// Create a map aggregate The value of data one treat as k To hold the
HashMap<Object,
Object> map = new HashMap<>();
//3 Traverse the value of test one
for (Integer e :ces1) {
// 4 Deposit in map Collection
map.put(e, 1);
}
//5 Traverse Test data 2 And map Of key compare If there is map Of k With test data 2 Value It will be added to list Collection
for (Integer a:ces2){
if (StringUtils.isNotBlank(Integer.toString(a))&& map.containsKey(a)){
list.add(a);
}
}
System.out.println(list);
}
Different values
Only need to map.containsKey(a) Change it to !map.containsKey(a)
边栏推荐
- Camera-memory内存泄漏分析(三)
- Webrtc series - 7-ice supplement of network transmission preference and priority
- Binary search
- Comparison of static methods and variables with instance methods and variables
- 软件调试测试的十大重要基本准则
- 第 4 篇:绘制四边形
- 2022.6.25 - leetcode. Un doigt d'épée. 091.
- [collection of good books] from technology to products
- EF core Basics
- 【LOJ#6718】九个太阳「弱」化版(循环卷积,任意模数NTT)
猜你喜欢
[MySQL] MySQL export database
Nepal graph learning Chapter 3_ Multithreading completes 6000w+ relational data migration
Some mobile phones open USB debugging, and the solution to installation failure
MySQL advanced part (IV: locking mechanism and SQL optimization)
评价——层次分析
第 4 篇:绘制四边形
MapReduce execution principle record
MySQL高级部分( 四: 锁机制、SQL优化 )
MySQL advanced Chapter 1 (installing MySQL under Linux) [2]
判断两个集合的相同值 ||不同值
随机推荐
(15)Blender源码分析之闪屏窗口显示菜单功能
Alibaba cloud function computing service one click to build Z-blog personal blog
【好书集锦】从技术到产品
2022.6.25 - leetcode. Un doigt d'épée. 091.
【Flink】Flink源码分析——批处理模式JobGraph的创建
2022.6.20-----leetcode. seven hundred and fifteen
Li Kou 79 word search
Intelligent manufacturing learning videos and books
MySQL common statements
[collection of good books] from technology to products
Binary search method
Uni app QR code scanning and identification function
刷题记录Day01
动态线段树leetcode.715
Small record of neural network learning 71 - tensorflow2 deep learning with Google Lab
在出海获客这件事上,数字广告投放之外,广告主还能怎么玩儿?
MySQL advanced part (IV: locking mechanism and SQL optimization)
Optimization - multi objective planning
Go time package: second, millisecond, nanosecond timestamp output
軟件調試測試的十大重要基本准則