当前位置:网站首页>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
边栏推荐
- 大文件如何快速上传?
- OPPO数据湖统一存储技术实践
- API gateway / API gateway (II) - use of Kong - load balancing
- HJ31 单词倒排
- 博睿数据携手F5共同构建金融科技从代码到用户的全数据链DNA
- Brute force of DVWA low -- > High
- Baidu written test 2022.4.12 + programming topic: simple integer problem
- Basic operation of sequential stack
- Compiling OpenSSL
- The win10 taskbar notification area icon is missing
猜你喜欢
1n5408-asemi rectifier diode
My raspberry PI zero 2W tossing notes record some problems encountered and solutions
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
How to upload large files quickly?
Role of asemi rectifier module mdq100-16 in intelligent switching power supply
eolink 如何助力遠程辦公
The wechat applet optimizes the native request through the promise of ES6
Basic operation of sequential stack
win10 任务栏通知区图标不见了
Leetcode151 - invert words in string - String - simulation
随机推荐
Flink DataStream 类型系统 TypeInformation
Leetcode165 compare version number double pointer string
UML learning_ Day2
Krpano panorama vtour folder and tour
Redis cluster principle
Leetcode162 - find peak - dichotomy - array
kubernetes之常用Pod控制器的使用
JUC learning record (2022.4.22)
Three uses of kprobe
Byte interview programming question: the minimum number of K
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
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
买卖股票的最佳时机系列问题
Compiling OpenSSL
8.3 language model and data set
The difference between having and where in SQL
How does eolink help telecommuting
Sqlserver transaction and lock problem
Async void caused the program to crash
Unity_ Code mode add binding button click event