当前位置:网站首页>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
边栏推荐
- Flink datastream type system typeinformation
- Share 3 tools, edit 5 works at home and earn more than 400
- Pnpm installation and use
- redis-shake 使用中遇到的错误整理
- SQL中HAVING和WHERE的区别
- Advanced version of array simulation queue - ring queue (real queuing)
- LeetCode162-寻找峰值-二分-数组
- PSYNC synchronization of redis source code analysis
- 重定向和请求转发详解
- JUC学习记录(2022.4.22)
猜你喜欢
每日一题-LeetCode396-旋转函数-递推
Lotus DB design and Implementation - 1 Basic Concepts
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
API gateway / API gateway (III) - use of Kong - current limiting rate limiting (redis)
Advanced version of array simulation queue - ring queue (real queuing)
What is the role of the full connection layer?
eolink 如何助力遠程辦公
Leetcode165 compare version number double pointer string
Sword finger offer (1) -- for Huawei
Detailed explanation of C language knowledge points - data types and variables [2] - integer variables and constants [1]
随机推荐
Ffmpeg installation error: NASM / yasm not found or too old Use --disable-x86asm for a clipped build
Advanced version of array simulation queue - ring queue (real queuing)
1n5408-asemi rectifier diode
Educational Codeforces Round 127 A-E题解
Practice of unified storage technology of oppo data Lake
Alexnet model
Analysis of common storage types and FTP active and passive modes
kubernetes之常用Pod控制器的使用
Redis主从同步
8.5 concise implementation of cyclic neural network
免费在upic中设置OneDrive或Google Drive作为图床
8.4 realization of recurrent neural network from zero
JS -- realize click Copy function
Borui data and F5 jointly build the full data chain DNA of financial technology from code to user
Modify the default listening IP of firebase emulators
Introduction to dirty reading, unrepeatable reading and phantom reading
win10 任务栏通知区图标不见了
Daily question - leetcode396 - rotation function - recursion
Lotus DB design and Implementation - 1 Basic Concepts
How does eolink help telecommuting