当前位置:网站首页>[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)
边栏推荐
- jsonUtils
- PCB封装下载网站推荐及其详细使用方法
- Oracle LiveLabs实验:Introduction to Oracle Spatial
- Graphics2D类基本使用
- Jin AI her power | impact tech, she can
- Graphics2d class basic use
- Kdd2022 | graphmae: self supervised mask map self encoder
- 2021 rust survey results released: 9354 questionnaires collected
- Oracle 19c 安装文档
- Have you really learned the common ancestor problem recently?
猜你喜欢

JVisualVM初步使用

User guide for JUC concurrency Toolkit

"Oracle database parallel execution" technical white paper reading notes

SQL调优指南笔记6:Explaining and Displaying Execution Plans

Turing prize winner: what should I pay attention to if I want to succeed in my academic career?

Ansible基础和常用模块(一)

How to write a vscode plug-in by yourself to realize plug-in freedom!

Have you really learned the common ancestor problem recently?

SQL调优指南笔记16:Managing Historical Optimizer Statistics

Oracle LiveLabs实验:Introduction to Oracle Spatial
随机推荐
Gzip compression decompression
June training (day 12) - linked list
Oracle LiveLabs实验:Introduction to Oracle Spatial Studio
[qnx hypervisor 2.2 manuel de l'utilisateur] 4.2 environnement de construction pris en charge
最近公共祖先问题你真的学会了吗?
复杂系统如何检测异常?北卡UNCC等最新《复杂分布式系统中基于图的深度学习异常检测方法综述》,阐述最新图异常检测技术进展
回文链表及链表相交问题(和心怡的人相交)你真的会了吗?
How to implement a simple publish subscribe mode
Oracle livelabs experiment: introduction to Oracle Spatial
Ansible playbook and ansible roles (III)
SQL tuning guide notes 12:configuring options for optimizer statistics gathering
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
经济学人聚焦WTO MC12:数字经济或成重要议题
SQL调优指南笔记13:Gathering Optimizer Statistics
Role of volatile keyword
Limit of advanced mathematics
SQL调优指南笔记10:Optimizer Statistics Concepts
How to write a vscode plug-in by yourself to realize plug-in freedom!
Ansible foundation and common modules (I)
如何自己动手写一个vscode插件,实现插件自由!