当前位置:网站首页>[leetcode] 577 reverse word III in string
[leetcode] 577 reverse word III in string
2022-07-02 15:36:00 【Crisp ~】
Given a string s , You need to reverse the character order of each word in the string , Keep the initial order of spaces and words .
Example 1:
Input : s = “Let’s take LeetCode contest”
Output : “s’teL ekat edoCteeL tsetnoc”
Example 2:
Input : s = “God Ding”
Output : “doG gniD”
Tips :
- 1 <= s.length <= 5 * 104
- s Include printable ASCII character .
- s Does not contain any beginning or ending spaces .
- s in At least There's a word .
- s All words in the are separated by a space .
# String segmentation , Reverse one by one , Merge
class Solution(object):
def reverseWords(self, s):
return " ".join([word[::-1] for word in s.split()])
边栏推荐
- LeetCode刷题——去除重复字母#316#Medium
- Facing the challenge of "lack of core", how can Feiling provide a stable and strong guarantee for customers' production capacity?
- MD5 encryption
- List set & UML diagram
- Leetcode skimming -- sum of two integers 371 medium
- LeetCode刷题——统计各位数字都不同的数字个数#357#Medium
- Pytorch 保存tensor到.mat文件
- 微信支付宝账户体系和支付接口业务流程
- 16_Redis_Redis持久化
- How does the computer set up speakers to play microphone sound
猜你喜欢
2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
LeetCode刷题——去除重复字母#316#Medium
02_ Linear table_ Sequence table
How to find a sense of career direction
Guangzhou Emergency Management Bureau issued a high temperature and high humidity chemical safety reminder in July
做好抗“疫”之路的把关人——基于RK3568的红外热成像体温检测系统
04_ 栈
17_Redis_Redis发布订阅
工程师评测 | RK3568开发板上手测试
【网络安全】网络资产收集
随机推荐
工程师评测 | RK3568开发板上手测试
Leetcode skimming -- count the number of numbers with different numbers 357 medium
Download blender on Alibaba cloud image station
14_ Redis_ Optimistic lock
06_ Stack and queue conversion
【LeetCode】189-轮转数组
. Solution to the problem of Chinese garbled code when net core reads files
LeetCode刷题——验证二叉树的前序序列化#331#Medium
20_Redis_哨兵模式
13_ Redis_ affair
【LeetCode】577-反转字符串中的单词 III
Yolo format data set processing (XML to txt)
12_ Redis_ Bitmap_ command
你不知道的Set集合
How to intercept the value of a key from the JSON string returned by wechat?
LeetCode刷题——两整数之和#371#Medium
密码学基础知识
Markdown tutorial
搭建自己的语义分割平台deeplabV3+
Leetcode skimming -- incremental ternary subsequence 334 medium