当前位置:网站首页>[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()])
边栏推荐
猜你喜欢
随机推荐
PTA 天梯赛习题集 L2-001 城市间紧急救援
LeetCode刷题——奇偶链表#328#Medium
Pytoch saves tensor to Mat file
03_线性表_链表
Case introduction and problem analysis of microservice
高考分数线爬取
How to choose a third-party software testing organization for automated acceptance testing of mobile applications
2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
MD5 encryption
02. After containerization, you must face golang
【LeetCode】877-石子游戏
士官类学校名录
工程师评测 | RK3568开发板上手测试
13_Redis_事务
Evaluation of embedded rz/g2l processor core board and development board of Feiling
Let your HMI have more advantages. Fet-g2ld-c core board is a good choice
高考录取分数线爬虫
Oracle primary key auto increment
【网络安全】网络资产收集
XML Configuration File









