当前位置:网站首页>[LeetCode] 反转字符串中的单词 III【557】
[LeetCode] 反转字符串中的单词 III【557】
2022-07-02 22:06:00 【山茶花开时。】
问题: 给定一个字符串s,你需要反转字符串中每个单词的字符顺序,同时仍保留空格和单词的初始顺序
示例1
输入: s = "Let's take LeetCode contest"
输出: "s'teL ekat edoCteeL tsetnoc"
示例2
输入: s = "God Ding"
输出: "doG gniD"
Python3解题
# 解法1
def reverseWords(s):
res = []
arrs = s.split(" ")
for val in arrs:
new_val = val[::-1]
res.append(new_val)
last_res = ' '.join(res)
return last_res
reverseWords("Let's take LeetCode contest")
reverseWords("God Ding")涉及知识点:
[Python] join()方法
https://blog.csdn.net/Hudas/article/details/122850092[Python] split()方法
https://blog.csdn.net/Hudas/article/details/122849811
边栏推荐
- [error record] the flutter reports an error (could not read script 'xxx\flutter\u tools\gradle\app\u plugin\u loader.gradle')
- Technological Entrepreneurship: failure is not success, but reflection is
- Web side defense Guide
- Try to get property'num for PHP database data reading_ rows' of non-object?
- How should programmers write logs
- 大话云原生之负载均衡篇-小饭馆客流量变大了
- Basic concepts of image and deep understanding of yuv/rgb
- [shutter] shutter opens a third-party application (url|launcher plug-in search and installation | url| launcher plug-in official example | open browser | open a third-party application)
- Market Research - current situation and future development trend of cell-based seafood market
- [QT] QT multithreading development - four methods to realize multithreading design
猜你喜欢

【ODX Studio编辑PDX】-0.1-如何快速查看各Variant变体间的支持的诊断信息差异(服务,Sub-Function...)

It's not easy to say I love you | use the minimum web API to upload files (swagger support) # yyds dry inventory #
![[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)](/img/2b/f31b81cedf37ca187bcaa20dfe0b83.png)
[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)
![NC24325 [USACO 2012 Mar S]Flowerpot](/img/cf/86acbcb524b3af0999ce887c877781.png)
NC24325 [USACO 2012 Mar S]Flowerpot

附加:【登录信息存储】与【登录状态校验】;(包括:总结了到目前为止,有关【登录信息存储】与【登录状态校验】的所有内容;)

Phpcms realizes the direct Alipay payment function of orders

Leetcode circular linked list (fast and slow pointer) code line by line interpretation

牛客网:最大子矩阵

An overview of the development of affective computing and understanding research

#include errors detected. Please update your includePath.
随机推荐
送给即将工作的自己
Oracle-PL/SQL编程
540. Single element in ordered array
影视随摘
杰理之充电拔出,无法触摸开机【篇】
PHP wechat red packet grabbing algorithm
Film and television excerpts
【AUTOSAR-DCM】-4.3-UDS $22和$2E服务如何读取和写入NVM数据
New feature of go1.18: trylock, which has been tossed n times
kubernetes 使用主机名将 pod 分配在指定节点上
What is the'function'keyword used in some bash scripts- What is the 'function' keyword used in some bash scripts?
[shutter] shutter gesture interaction (small ball following the movement of fingers)
[QT] QT multithreading development - reentrancy and thread safety
UE4 游戏架构 学习笔记
Unity3d learning notes 4 - create mesh advanced interface
Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
Source code analysis - lightweight asynchronous crawler framework Ruia
数学建模——图与网络模型及方法(一)
App page sharing password rails implementation
Notes on key vocabulary in the English original of the biography of jobs (10) [chapter eight]