Strobogrammatic Number 系列 LC解题记录(未完成)

该系列共三道题,Company Tag只有一个Google,那就必须要做了。

第一题题目内容

A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

Write a function to determine if a number is strobogrammatic. The number is represented as a string.

For example, the numbers "69", "88", and "818" are all strobogrammatic.

解决思路

直接按照题目要求来,人家要什么就给什么,这题要求判断,那就判断。从两头开始,我这边是1,那翻过来还是1,0和8都是,有区别的就是6和9,因为上下颠倒很有可能导致性别的不同,所以左边是6的话,对称位置必须是9。所以这题先建立一个对应的map,然后扫一遍字符串就可以了。

code

复杂度分析

第二题题目内容

A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

Find all strobogrammatic numbers that are of length = n.

For example,
Given n = 2, return ["11","69","88","96"].

解决思路

一看关键词find/return all #$%^,通常都是DFS,深搜一遍,挖地三尺,雁过拔毛。

code

复杂度分析

第三题题目内容

A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

Write a function to count the total strobogrammatic numbers that exist in the range of low <= num <= high.

For example,
Given low = "50", high = "100", return 3. Because 69, 88, and 96 are three strobogrammatic numbers.

Note:
Because the range might be a large number, the low and high numbers are represented as string.

解决思路

code

复杂度分析

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值