当前位置:网站首页>Do keyword search, duplicate keyword search, or do not match
Do keyword search, duplicate keyword search, or do not match
2022-04-23 15:14:00 【A run】
public static Boolean check(List<String> list, String city) {
for (String s : list) {
if (s.equals(city)) {
return true;
}
}
return false;
}
public static void main(String[] args) {
List<String> city = new ArrayList<String>();//1,3,7,13
city.add(" Shanghai ");
city.add(" Beijing ");
city.add(" Shenzhen ");
city.add(" nanjing ");
List<String> tempList = new ArrayList<String>();
for (String c : city) {
StringBuffer str = new StringBuffer();
str.append(c);
if (!tempList.contains(c)) {
tempList.add(c);
}
StringBuffer str2 = new StringBuffer();
for (String s : city) {
if (str2.length() > 0) {
str2.append(",").append(s);
} else {
str2.append(s);
}
String[] split2 = str2.toString().split(",");
Arrays.sort(split2);
String data2 = String.join(",", split2);
if (!tempList.contains(data2) && !check(tempList, data2)) {
tempList.add(data2);
} else {
str2 = new StringBuffer();
}
if (!c.equals(s)) {
if (str.length() > 0) {
str.append(",").append(s);
} else {
str.append(s);
}
String[] split = str.toString().split(",");
Arrays.sort(split);
String data = String.join(",", split);
if (!tempList.contains(data) && !check(tempList, data)) {
tempList.add(data);
}
}
}
String[] split = str.toString().split(",");
Arrays.sort(split);
String data = String.join(",", split);
if (!tempList.contains(data) && !check(tempList, data)) {
tempList.add(data);
}
}
tempList.forEach(e -> {
System.out.println(e);
});
}
Shanghai
Beijing
Shanghai , Beijing
Beijing , Shenzhen
Shanghai , Beijing , Shenzhen
Beijing , nanjing , Shenzhen
Shanghai , Beijing , nanjing , Shenzhen
Shenzhen
nanjing , Shenzhen
Shanghai , Shenzhen
nanjing
Shanghai , nanjing
Shanghai , Beijing , nanjing
版权声明
本文为[A run]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231407312655.html
边栏推荐
- How to design a good API interface?
- How does eolink help telecommuting
- Tencent has written a few words, Ali has written them all for a month
- Analysis of common storage types and FTP active and passive modes
- Application of skiplist in leveldb
- tcp_ Diag kernel related implementation 1 call hierarchy
- January 1, 1990 is Monday. Define the function date_ to_ Week (year, month, day), which realizes the function of returning the day of the week after inputting the year, month and day, such as date_ to
- Share 20 tips for ES6 that should not be missed
- Ffmpeg installation error: NASM / yasm not found or too old Use --disable-x86asm for a clipped build
- TLS / SSL protocol details (28) differences between TLS 1.0, TLS 1.1 and TLS 1.2
猜你喜欢
免费在upic中设置OneDrive或Google Drive作为图床
8.5 concise implementation of cyclic neural network
Brute force of DVWA low -- > High
LeetCode162-寻找峰值-二分-数组
Thinkphp5 + data large screen display effect
Lotus DB design and Implementation - 1 Basic Concepts
我的 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
Five data types of redis
Leetcode151 - invert words in string - String - simulation
nuxt项目:全局获取process.env信息
随机推荐
My raspberry PI zero 2W tossing notes record some problems encountered and solutions
让阿里P8都为之着迷的分布式核心原理解析到底讲了啥?看完我惊了
分布式事务Seata介绍
js——实现点击复制功能
Basic operation of circular queue (Experiment)
Detailed analysis of SQL combat of Niuke database (26-30)
Subnet division of flannel principle
The life cycle of key value in redis module programming
JS -- realize click Copy function
asp. Net method of sending mail using mailmessage
TLS / SSL protocol details (28) differences between TLS 1.0, TLS 1.1 and TLS 1.2
Will golang share data with fragment append
For 22 years, you didn't know the file contained vulnerabilities?
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
我的树莓派 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
小红书 timestamp2 (2022/04/22)
1990年1月1日是星期一,定义函数date_to_week(year,month,day),实现功能输入年月日后返回星期几,例如date_to_week(2020,11,1),返回:星期日。 提示:
LeetCode167-两数之和II-双指针-二分-数组-查找
调度系统使用注意事项