当前位置:网站首页>【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()])
边栏推荐
- How to choose a third-party software testing organization for automated acceptance testing of mobile applications
- 06_栈和队列转换
- How to test tidb with sysbench
- LeetCode刷题——统计各位数字都不同的数字个数#357#Medium
- LeetCode刷题——验证二叉树的前序序列化#331#Medium
- 怎样从微信返回的json字符串中截取某个key的值?
- LeetCode_ String_ Simple_ 412.Fizz Buzz
- Learn the method code example of converting timestamp to uppercase date using PHP
- Data analysis thinking analysis methods and business knowledge - business indicators
- Application of CDN in game field
猜你喜欢

. Net again! Happy 20th birthday

Solve the problem of frequent interruption of mobaxterm remote connection

MySQL calculate n-day retention rate

How to find a sense of career direction

让您的HMI更具优势,FET-G2LD-C核心板是个好选择

03.golang初步使用

Leetcode skimming -- count the number of numbers with different numbers 357 medium

Map introduction

List集合&UML图

彻底弄懂浏览器强缓存和协商缓存
随机推荐
List set & UML diagram
5. Practice: jctree implements the annotation processor at compile time
4. Data splitting of Flink real-time project
folium,确诊和密接轨迹上图
17_ Redis_ Redis publish subscription
Build your own semantic segmentation platform deeplabv3+
03_ Linear table_ Linked list
03.golang初步使用
Deploy tidb cluster with tiup
Leetcode skimming - remove duplicate letters 316 medium
Topology architecture of the minimum deployment of tidb cluster
Tidb hybrid deployment topology
. Solution to the problem of Chinese garbled code when net core reads files
Redux——详解
JVM architecture, classloader, parental delegation mechanism
There are 7 seats with great variety, Wuling Jiachen has outstanding product power, large humanized space, and the key price is really fragrant
08_ strand
04_ Stack
03_线性表_链表
损失函数与正负样本分配:YOLO系列