当前位置:网站首页>[Jianzhi offer] Jianzhi offer 05 Replace spaces
[Jianzhi offer] Jianzhi offer 05 Replace spaces
2022-06-12 21:52:00 【Caicai 2022】
subject
Code
【 Method 1】
Execution time :32 ms, In all Python3 Defeated in submission 72.46% Users of
Memory consumption :15 MB, In all Python3 Defeated in submission 53.18% Users of
Pass the test case :27 / 27
class Solution:
def replaceSpace(self, s: str) -> str:
s=s.replace(" ","%20")
return s
【 Method 2】
Execution time :32 ms, In all Python3 Defeated in submission 72.46% Users of
Memory consumption :14.9 MB, In all Python3 Defeated in submission 78.35% Users of
Pass the test case :27 / 27
class Solution:
def replaceSpace(self, s: str) -> str:
ans=""
for item in s:
if ord(item)==32:
ans+="%20"
else:
ans+=item
return ans
【 Method 3】
Execution time :40 ms, In all Python3 Defeated in submission 19.32% Users of
Memory consumption :14.9 MB, In all Python3 Defeated in submission 60.09% Users of
Pass the test case :27 / 27
class Solution:
def replaceSpace(self, s: str) -> str:
ss=s.split(' ')
return "%20".join(ss)
边栏推荐
- 六月集训(第12天) —— 链表
- Digraph deep copy
- 回文链表及链表相交问题(和心怡的人相交)你真的会了吗?
- Is it safe to open an account in tonghuashun? How to open an account
- 【QNX Hypervisor 2.2 用户手册】4.3 获取host组件
- SQL tuning guide notes 9:joins
- 【QNX Hypervisor 2.2 用户手册】4.2 支持的构建环境
- Ansible playbook和Ansible Roles(三)
- Cookies and sessions
- Ansible summary (VI)
猜你喜欢

SQL tuning guide notes 13:gathering optimizer statistics

Okio source code analysis

MySQL introduction and installation (I)

NiO User Guide

Ansible基础和常用模块(一)

SQL调优指南笔记18:Analyzing Statistics Using Optimizer Statistics Advisor

How do complex systems detect anomalies? North Carolina UNCC and others' latest overview of graph based deep learning anomaly detection methods in complex distributed systems describes the latest prog

Ansible playbook和Ansible Roles(三)

Oracle livelabs experiment: introduction to Oracle Spatial

利用ADG Standby克隆PDB
随机推荐
Ansible基础和常用模块(一)
Is it safe to open an account in tonghuashun? How to open an account
图灵奖得主:想要在学术生涯中获得成功,需要注意哪些问题?
What is the race condition? How do you find and solve the competition?
Pixel level reconstruction and restoration technology to solve severe image blur
SQL调优指南笔记15:Controlling the Use of Optimizer Statistics
PE安装win10系统
Icml2022 | Galaxy: apprentissage actif des cartes de polarisation
Vagrantbox reinstalling the vboxsf driver
“Oracle数据库并行执行”技术白皮书读书笔记
February 27th
SQL调优指南笔记13:Gathering Optimizer Statistics
June training (day 10) - bit operation
SQL调优指南笔记10:Optimizer Statistics Concepts
SQL tuning guide notes 14:managing extended statistics
大一下学年学期总结
MySql主从复制
How do complex systems detect anomalies? North Carolina UNCC and others' latest overview of graph based deep learning anomaly detection methods in complex distributed systems describes the latest prog
Have you really learned the common ancestor problem recently?
数据批量写入