当前位置:网站首页>[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
边栏推荐
- Unity发布WebGL播放声音的一种方法
- Market Research - current market situation and future development trend of night vision goggles for pilots
- 电商系统微服务架构
- Notes on key vocabulary of the original English book biography of jobs (IX) [chapter seven]
- 【AUTOSAR-DCM】-4.3-UDS $22和$2E服务如何读取和写入NVM数据
- NC50965 Largest Rectangle in a Histogram
- Methods of adding styles to native JS
- 傑理之修改不需要長按開機功能【篇】
- Objects and object variables
- Server response status code
猜你喜欢

An overview of the development of affective computing and understanding research

对象与对象变量

Socket socket c/s end process

#include errors detected. Please update your includePath.

电商系统微服务架构

图形视图框架
![[shutter] shutter resource file use (import resource pictures | use image resources)](/img/e9/94ae2e3ee315f490eb3cf14bcf2e49.jpg)
[shutter] shutter resource file use (import resource pictures | use image resources)

wait解决僵尸进程
![[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)](/img/f7/cb41d159e5c5ef3f4f1b9468d52ccc.jpg)
[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)

Lightgbm principle and its application in astronomical data
随机推荐
基于ASP.net的手机销售管理系统(二手手机销售管理系统)+ASP.NET+C#语言+VS2010+数据库可以用于课设、毕设学习
Tencent three sides: in the process of writing files, the process crashes, and will the file data be lost?
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
U++ 学习笔记 ----松弛
解决 excel 文件上传时更改选中的文件出现错误net::ERR_UPLOAD_FILE_CHANGED
Source code analysis - lightweight asynchronous crawler framework Ruia
Unity3d learning notes 4 - create mesh advanced interface
Additional: [login information storage] and [login status verification]; (including: summarizing all the contents of [login information storage] and [login status verification] so far;)
Introduction to database system Chapter 1 short answer questions - how was the final exam?
杰理之内置短按再长按,不管长按多长时间都是短按【篇】
#include errors detected. Please update your includePath.
U++ 原始内存 学习笔记
Oracle cursor
App page sharing password rails implementation
图形视图框架
Dynamic memory allocation (malloc calloc realloc free)
杰理之如何测试按键的误触率【篇】
Meibeer company is called "Manhattan Project", and its product name is related to the atomic bomb, which has caused dissatisfaction among Japanese netizens
Market Research - current market situation and future development trend of third-party data platform
phpcms实现订单直接支付宝支付功能