当前位置:网站首页>不会就坚持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);
}
}
边栏推荐
- opengauss预检查安装
- There is a special cryptology language called asn.1
- 通过PWM呼吸灯和PWM控制直流电机来详细介绍TIM的输出比较功能
- First knowledge of C language (3)
- C语言实现三子棋游戏(详解)
- Note: restframe work records many to one tables, how to serialize in that table (reverse query)
- Const char* and char*, string constants
- The return value of the function is the attention of the pointer, the local variables inside the static limit sub function, and how the pointer to the array represents the array elements
- [kvm] common commands
- 不会就坚持67天吧 平方根
猜你喜欢

不会就坚持63天吧 最大的异或

Copy products with one click from Taobao, tmall, 1688, wechat, jd.com, Suning, taote and other platforms to pinduoduo platform (batch upload baby details Interface tutorial)

Problems encountered in vscode connection SSH

MPU6050

Compilation and linking

First knowledge of C language (3)

Machine vision Series 1: Visual Studio 2019 dynamic link library DLL establishment

力扣面试题17.04 消失的数字||260.只出现一次的数字(内含位运算知识点)

How to solve the problem of store ranking?

Data mining -- code implementation of association analysis example (Part 2)
随机推荐
[kvm] install KVM
SQL time fuzzy query datediff() function
Methods of using multiple deformations on an element
MPU6050
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
SQL server how to judge when the parameter received by the stored procedure is of type int?
C语言力扣第61题之旋转链表。双端队列与构造循环链表
Asp. Net MVC, how can the controller in the folder jump to the controller in the root directory?
Pat a1069/b1019 the black hole of numbers
Don't the JDBC SQL connector of the big guys Flink now support all databases, such as vertica?
The function "postgis_version" cannot be found when installing PostGIS
Object array merges elements according to a field
Labelme cannot open the picture
Lua language (stm32+2g/4g module) and C language (stm32+esp8266) methods of extracting relevant data from strings - collation
不会就坚持71天吧 链表排序
Class starts! See how smardaten decomposes complex business scenarios
Mmdetection preliminary use
Leftmost prefix principle of index
对一个元素使用多种变形的方法
Wechat applet parameter transfer