当前位置:网站首页>Sword finger offer46 translates numbers into strings
Sword finger offer46 translates numbers into strings
2022-07-26 20:34:00 【It was the sea】
Given a number , We translate it as a string according to the following rules :0 Translate into “a” ,1 Translate into “b”,……,11 Translate into “l”,……,25 Translate into “z”. A number may have more than one translation . Please program a function , Used to calculate how many different translation methods a number has .
class Solution:
def translateNum(self, num: int) -> int:
s = str(num)
a = b = 1
for i in range(2, len(s) + 1):
tmp = s[i - 2:i]
c = a + b if "10" <= tmp <= "25" else a
b = a
a = c
return a
边栏推荐
- 任务一 报告
- Cookies and sessions
- 贴合课标新方向 猿辅导打造特色新概念内容体系
- 数字化工厂有哪些关键技术
- Introduction to component functions of blueprism process business object Chapter 3 of RPA
- 小场景带来大提升!百度飞桨EasyDL助力制造业流水线AI升级
- NVIDIA Canvas 初体验~
- 7.25模拟赛总结
- 谷歌的新编程语言被称为 Carbon
- Fitting the new direction of curriculum standards, ape guidance, creating a characteristic new concept content system
猜你喜欢

Game partner topic: breederdao and ultiverse have established a new metauniverse
![[experiment sharing] CCIE BGP routing black hole experiment]](/img/c8/7ccb879ad7c739d3573637fd14f4e1.png)
[experiment sharing] CCIE BGP routing black hole experiment]

Kotlin - 协程上下文 CoroutineContext

小公司小而美的产品,如何突围?

Intranet penetration learning (II) information collection

游戏合作伙伴专题:BreederDAO 与 Ultiverse 建立了一个新的元宇宙

Experiment 6 BGP federal comprehensive experiment

一文读懂 Kubernetes的四种服务类型!

Chat software project development 2

Bean injection and lifecycle
随机推荐
T246836 [lsot-1] potatoes of Tyrannosaurus Rex
Read the four service types of kubernetes!
EasyCVR设备管理列表页面,分页数据不显示的问题修复
SwiftUI 4 新功能之实时获取点击位置 .onTapGesture { location in} (教程含源码)
Group convolution
Correct the classpath of your application so that it contains compatible versions of the classes com
MPLS 多协议标签交换技术
QT driving school subject examination system -- from implementation to release
使用百度飞桨 EasyDL 完成垃圾分类
The typing competition is over!
QT信号与槽连接(松耦合)
[experiment sharing] CCIE BGP routing black hole experiment]
美国应用材料公司宣布将以22亿美元现金收购国际电气
Kotlin - 协程上下文 CoroutineContext
【【实验分享】CCIE—BGP路由黑洞实验】
Gbase learning - install gbase 8A MPP cluster v95
BGP的路由黑洞和防环
Where are the single dogs in the evening of 5.20?
【刷题记录】22. 括号生成
How to obtain Cu block partition information in HM and draw with MATLAB