当前位置:网站首页>[leetcode] reverse the word III in the string [557]
[leetcode] reverse the word III in the string [557]
2022-07-02 22:52:00 【When camellia flowers bloom.】
problem : 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"
Python3 Problem solving
# solution 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")Knowledge points involved :
[Python] join() Method
https://blog.csdn.net/Hudas/article/details/122850092[Python] split() Method
https://blog.csdn.net/Hudas/article/details/122849811
边栏推荐
- Notes on key vocabulary in the English original of the biography of jobs (10) [chapter eight]
- Pointer - function pointer
- SimpleITK使用——3. 常见操作
- 《乔布斯传》英文原著重点词汇笔记(十)【 chapter eight】
- U++ 原始内存 学习笔记
- Introduction to database system Chapter 1 short answer questions - how was the final exam?
- Introduction and response to high concurrency
- #include errors detected. Please update your includePath.
- 【板栗糖GIS】arcscene—如何做出有高度的高程图
- 数学建模——图与网络模型及方法(一)
猜你喜欢

百度智能云-创建人脸识别应用
![NC24325 [USACO 2012 Mar S]Flowerpot](/img/cf/86acbcb524b3af0999ce887c877781.png)
NC24325 [USACO 2012 Mar S]Flowerpot

Get off work on time! Episode 6 of Excel Collection - how to split and count document amounts

手写ORM(对象关系映射)增删改查

Mathematical modeling -- graph and network models and methods (I)

wait解决僵尸进程

附加:【登录信息存储】与【登录状态校验】;(包括:总结了到目前为止,有关【登录信息存储】与【登录状态校验】的所有内容;)
![[LeetCode] 反转字符串中的单词 III【557】](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[LeetCode] 反转字符串中的单词 III【557】

位的高阶运算

Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
随机推荐
牛客网:龙与地下城游戏
uniapp微信登录返显用户名和头像
Server response status code
Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
服务器响应状态码
Introduction to database system Chapter 1 short answer questions - how was the final exam?
Pointer array parameter passing, pointer parameter passing
Notes on key vocabulary of the original English book biography of jobs (IX) [chapter seven]
[LeetCode] 存在重复元素【217】
Build your own website (22)
[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)
Gas station [problem analysis - > problem conversion - > greed]
送给即将工作的自己
Share 10 JS closure interview questions (diagrams), come in and see how many you can answer correctly
[foreign journal] sleep and weight loss
Get off work on time! Episode 6 of Excel Collection - how to split and count document amounts
P1007 独木桥
【板栗糖GIS】arcmap—如何批量修改注记要素的字体,颜色,大小等
Oracle-PL/SQL编程
杰理之修改不需要长按开机功能【篇】