当前位置:网站首页>[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
边栏推荐
- DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
- 服务器响应状态码
- Oracle cursor
- Go four singleton modes
- JS获取display为none的隐藏元素的宽度和高度的解决方案
- [autosar-dcm] - 4.3-how UDS $22 and $2e services read and write NVM data
- JS syntax ES6, ES7, es8, es9, ES10, es11, ES12 new features (Abstract)
- Based on asp Net (used mobile phone sales management system) +asp Net+c # language +vs2010+ database can be used for course design and post design learning
- 加油站[问题分析->问题转换->贪心]
- Phpcms realizes the direct Alipay payment function of orders
猜你喜欢
数组进阶提高
Hanging mirror security won four global infosec awards on rsac2022
手写ORM(对象关系映射)增删改查
Graphic view frame
悬镜安全在RSAC2022上斩获Global InfoSec Awards四项大奖
Dynamic memory allocation (malloc calloc realloc free)
【板栗糖GIS】arcmap—为什么使用自定义捕捉的时候,经典捕捉的勾要去掉呢?
Wait to solve the zombie process
Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises
【外刊】睡眠与减肥
随机推荐
JS solution for obtaining the width and height of hidden elements whose display is none
How can I use knockout's $parent/$root pseudovariables from inside a . computed() observable?
How should programmers write logs
Comprehensively analyze the logic of the shared purchase business model? How sharing purchase empowers Enterprises
Jerry's modification does not require long press the boot function [chapter]
NC50965 Largest Rectangle in a Histogram
杰理之内置短按再长按,不管长按多长时间都是短按【篇】
[QT] Q multithreaded development - Analysis of multithreaded application examples (Mandelbrot)
Oracle PL / SQL programming
'when to use const char * and when to use const char []' - when to use const char * and when to use const char []
杰理之内置关机电流 1.2uA,之后不能长按开机【篇】
U++ 学习笔记 堆
【微服务|Sentinel】重写sentinel的接口BlockExceptionHandler
It's not easy to say I love you | use the minimum web API to upload files (swagger support) # yyds dry inventory #
Xiaopeng P7 had an accident and the airbag did not pop up. Is this normal?
Get off work on time! Episode 6 of Excel Collection - how to split and count document amounts
【洛谷P1541】乌龟棋【DP】
I admire that someone explained such an obscure subject as advanced mathematics so easily
《乔布斯传》英文原著重点词汇笔记(九)【 chapter seven】
Socket套接字C/S端流程