当前位置:网站首页>不会就坚持59天吧 替换单词
不会就坚持59天吧 替换单词
2022-07-29 04:13:00 【一只小小明】

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);
}
}
边栏推荐
- %s. %c, character constant, string constant, const char*, pointer array, string array summary
- 不会就坚持71天吧 链表排序
- The difference between dynamic, VaR and object in fluent
- Is the array name a pointer
- 不会就坚持62天吧 单词之和
- RMAN do not mark expired backups
- Pat a1069/b1019 the black hole of numbers
- Beginner: array & String
- Openfeign asynchronous call problem
- Press the missing number of interview question 17.04 | | 260. the number that appears only once (including bit operation knowledge points)
猜你喜欢
随机推荐
Don't the JDBC SQL connector of the big guys Flink now support all databases, such as vertica?
JS realizes the function of one click Copy
请问为什么我进行mysql数据update时,kafka中采集到的是先删除原纪录(op d)再新增新
数据集成这个地方的过滤条件该咋写,用的啥语法?sql语法处理bizdate可以不
不会就坚持68天吧 狒狒吃香蕉
The function "postgis_version" cannot be found when installing PostGIS
Data mining -- Introduction to the basis of association analysis (Part 1)
有没有大佬帮我看下flink sql连接kafka认证kerberos的参数配置是否有误
不会就坚持69天吧 合并区间
编译与链接
The output comparison function of Tim is introduced in detail through PWM breathing lamp and PWM controlled DC motor
Some problems about pointers
Communication between parent-child components and parent-child components provide and inject
Codeforces round 810 (Div. 2) d. rain (segment tree difference)
Database SQL statement realizes function query of data decomposition
C语言:结构体简单语法总结
Object array merges elements according to a field
这个报错是什么鬼啊,不影响执行结果,但是在执行sql时一直报错。。。连接maxComputer是使用
What the hell is this error? It doesn't affect the execution result, but it always reports errors when executing SQL... Connecting maxcomputer uses
[untitled]









