当前位置:网站首页>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
边栏推荐
- tkinter使用wpf控件
- [基础服务] [数据库] ClickHouse的安装和配置
- Depthwiseseparableconvolution: depthwise convolution and pointwise convolution
- 破题数据中心绿色可持续发展
- Typescript asynchronous function promise use
- Fitting the new direction of curriculum standards, ape guidance, creating a characteristic new concept content system
- tf.GraphKeys
- 传惠普/戴尔/微软/亚马逊考虑将部分硬件生产线转到大陆以外
- 解决IBGP的水平分割和BGP选路原则
- How to obtain Cu block partition information in HM and draw with MATLAB
猜你喜欢
随机推荐
[pyqt5 basic control usage analysis]
Principle and application of one click login of local number (glory Collection Edition)
Group convolution
When there are many query fields, you can add ordinary query and advanced query
EtherCAT synchronization mode
Kotlin - 协程构建器 CoroutineBuilder
[基础服务] [数据库] ClickHouse的安装和配置
[record of question brushing] 22. bracket generation
Using questpdf operation to generate PDF is faster and more efficient!
【刷题记录】22. 括号生成
BGP的路由黑洞和防环
Solve the horizontal segmentation of iBGP and BGP routing principles
英国德国相继推出5G商用服务,华为成幕后功臣
美司法部律师团队要求法官拒绝受理华为诉讼
消息队列知识点总结
美国应用材料公司宣布将以22亿美元现金收购国际电气
深度可分离卷积(DepthwiseSeparableConvolution):Depthwise卷积与Pointwise卷积
Leetcode刷题之——链表总结
李彦宏遭“泼冷水”热情不减!百度结盟华为麒麟,发布“鸿鹄”芯片
Easycvr device management list page, paging data does not display problem repair









