当前位置:网站首页>No, just stick to it for 59 days
No, just stick to it for 59 days
2022-07-29 04:16:00 【A little Ming】
class Solution {
public String replaceWords(List<String> dictionary, String sentence) {
Set<String> dictionarySet = new HashSet<String>();
for (String root : dictionary) {
dictionarySet.add(root);
}
String[] words = sentence.split(" ");
for (int i = 0; i < words.length; i++) {
String word = words[i];
for (int j = 0; j < word.length(); j++) {
if (dictionarySet.contains(word.substring(0, 1 + j))) {
words[i] = word.substring(0, 1 + j);
break;
}
}
}
return String.join(" ", words);
}
}
边栏推荐
- Machine vision series 3:vs2019 opencv environment configuration
- Two forms of softmax cross entropy + numpy implementation
- Class starts! See how smardaten decomposes complex business scenarios
- 有一种密码学专用语言叫做ASN.1
- Installation and use of stm32cubemx (5.3.0)
- C语言:结构体简单语法总结
- HC06 HC05 BT
- 数据源是SQL server ,我要配置日期字段 updateDate 最后两天日期的增量数据,做增
- Cad2020 introductory learning (2021.4.13)
- Multi rotor six axis hardware selection
猜你喜欢
14.haproxy+keepalived负载均衡和高可用
不会就坚持64天吧 查找插入位置
MPU6050
Blood cases caused by < meta charset=UTF-8> -- Analysis of common character codes
Machine vision Series 1: Visual Studio 2019 dynamic link library DLL establishment
How to solve the problem of store ranking?
Installation and use of stm32cubemx (5.3.0)
Common components of solder pad (2021.4.6)
不会就坚持63天吧 最大的异或
Whole house WiFi solution: mesh router networking and ac+ap
随机推荐
小程序:区域滚动、下拉刷新、上拉加载更多
MPU6050
对一个元素使用多种变形的方法
Openfeign asynchronous call problem
Safari's compatibility with Z-index
不会就坚持60天吧 神奇的字典
Record of problems encountered in ROS learning
Target detection learning process
不会就坚持68天吧 狒狒吃香蕉
[kvm] create virtual machine from kickstart file
C declaration and initialization and assignment
Incubator course design (April 12, 2021)
不会就坚持71天吧 链表排序
kotlin的List,Map,Set等集合类不指定类型
How to query the submission number of a version
Model tuning, training model trick
The data source is SQL server. I want to configure the incremental data of the last two days of the date field updatedate to add
The solution of porting stm32f103zet6 program to c8t6+c8t6 download program flash timeout
不会就坚持70天吧 数组中第k大的数
通过js来实现一元二次方程的效果,输入a,b,c系数后可计算出x1和x2的值