当前位置:网站首页>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
边栏推荐
- Leetcode167 - sum of two numbers II - double pointer - bisection - array - Search
- Async void caused the program to crash
- Llvm - generate local variables
- Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]
- 让阿里P8都为之着迷的分布式核心原理解析到底讲了啥?看完我惊了
- 我的 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
- 分享3个使用工具,在家剪辑5个作品挣了400多
- Detailed explanation of C language knowledge points - data types and variables [2] - integer variables and constants [1]
- 免费在upic中设置OneDrive或Google Drive作为图床
- 买卖股票的最佳时机系列问题
猜你喜欢

Sword finger offer (2) -- for Huawei

win10 任务栏通知区图标不见了

LeetCode165-比较版本号-双指针-字符串

API gateway / API gateway (II) - use of Kong - load balancing

What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier

Leetcode165 compare version number double pointer string

如何设计一个良好的API接口?

Nuxt project: Global get process Env information

Reptile exercises (1)
![Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]](/img/c6/5241de0d670da3dae136a3047c6160.jpg)
Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]
随机推荐
Llvm - generate addition
UML学习_day2
Lotus DB design and Implementation - 1 Basic Concepts
LeetCode162-寻找峰值-二分-数组
我的 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
Is asemi ultrafast recovery diode interchangeable with Schottky diode
Pnpm installation and use
1990年1月1日是星期一,定义函数date_to_week(year,month,day),实现功能输入年月日后返回星期几,例如date_to_week(2020,11,1),返回:星期日。 提示:
Nuxt project: Global get process Env information
小红书 timestamp2 (2022/04/22)
免费在upic中设置OneDrive或Google Drive作为图床
Grep was unable to redirect to the file
Role of asemi rectifier module mdq100-16 in intelligent switching power supply
API gateway / API gateway (III) - use of Kong - current limiting rate limiting (redis)
Baidu written test 2022.4.12 + programming topic: simple integer problem
Mysql连接查询详解
Basic operation of sequential stack
【thymeleaf】处理空值和使用安全操作符
中富金石财富班29800效果如何?与专业投资者同行让投资更简单
Have you learned the basic operation of circular queue?