当前位置:网站首页>【LeetCode】577-反转字符串中的单词 III
【LeetCode】577-反转字符串中的单词 III
2022-07-02 12:09:00 【酥酥~】
给定一个字符串 s ,你需要反转字符串中每个单词的字符顺序,同时仍保留空格和单词的初始顺序。
示例 1:
输入: s = “Let’s take LeetCode contest”
输出: “s’teL ekat edoCteeL tsetnoc”
示例 2:
输入: s = “God Ding”
输出: “doG gniD”
提示:
- 1 <= s.length <= 5 * 104
- s 包含可打印的 ASCII 字符。
- s 不包含任何开头或结尾空格。
- s 里 至少 有一个词。
- s 中的所有单词都用一个空格隔开。
#字符串分割,逐个反转,合并
class Solution(object):
def reverseWords(self, s):
return " ".join([word[::-1] for word in s.split()])
边栏推荐
- 05_队列
- Force deduction solution summarizes the lucky numbers in 1380 matrix
- Redux - detailed explanation
- Leetcode skimming -- incremental ternary subsequence 334 medium
- Application and practice of Jenkins pipeline
- 你不知道的Set集合
- Guangzhou Emergency Management Bureau issued a high temperature and high humidity chemical safety reminder in July
- 工程师评测 | RK3568开发板上手测试
- 怎样从微信返回的json字符串中截取某个key的值?
- Practical debugging skills
猜你喜欢

4. Jctree related knowledge learning

搭建自己的语义分割平台deeplabV3+

06_ Stack and queue conversion

Be a good gatekeeper on the road of anti epidemic -- infrared thermal imaging temperature detection system based on rk3568

How does the computer set up speakers to play microphone sound

基于RZ/G2L | OK-G2LD-C开发板存储读写速度与网络实测

. Solution to the problem of Chinese garbled code when net core reads files

03_ Linear table_ Linked list

07_哈希

SQL stored procedure
随机推荐
05_队列
夏季高考文化成绩一分一段表
03_線性錶_鏈錶
让您的HMI更具优势,FET-G2LD-C核心板是个好选择
飞凌嵌入式RZ/G2L处理器核心板及开发板上手评测
【网络安全】网络资产收集
21_ Redis_ Analysis of redis cache penetration and avalanche
How to write sensor data into computer database
党史纪实主题公益数字文创产品正式上线
List set & UML diagram
Leetcode skimming - remove duplicate letters 316 medium
11_Redis_Hyperloglog_命令
Tidb data migration scenario overview
Application of CDN in game field
做好抗“疫”之路的把关人——基于RK3568的红外热成像体温检测系统
自定义异常
XML Configuration File
Libcurl Lesson 13 static library introduces OpenSSL compilation dependency
Application and practice of Jenkins pipeline
17_ Redis_ Redis publish subscription