资讯专栏INFORMATION COLUMN

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

王晗 / 3119人阅读

摘要:所以这题先建立一个对应的,然后扫一遍字符串就可以了。复杂度分析第二题题目内容解决思路一看关键词,通常都是,深搜一遍,挖地三尺,雁过拔毛。复杂度分析第三题题目内容解决思路复杂度分析

该系列共三道题,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 复杂度分析

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/64978.html

相关文章

  • 246. 247. 248. Strobogrammatic Number I II II

    摘要:题目解答题目解答先考虑最底层的两种情况,当和当的时候,就是最中间的数为空还是存在唯一的一个数。然后我们在这个基础上,用循环两个数两个数地一起向外扩张。扩张后的结果存在里,作为再服务于上一层的扩张,得到最终结果。 246.Strobogrammatic NumberI题目:A strobogrammatic number is a number that looks the same w...

    Fundebug 评论0 收藏0
  • Compare Version Numbers LC解题记录

    摘要:题目内容比较不同的版本号,并根据大小返回,或。并提醒版本意思是第二代的第五次升级,反正不是数字上的的意思。代码拆分两个字符串这里用最大的长度作为循环范围因为循环范围是最大长度,所以缺的位置补复杂度分析,和分别是两个字符串的长度。 题目内容 比较不同的版本号,并根据大小返回-1,1或0。并提醒2.5版本意思是第二代的第五次升级,反正不是数字上的2.5的意思。 解决思路 直观的想法是,找到...

    wanglu1209 评论0 收藏0
  • Next Permutation LC解题记录

    摘要:解决思路有一首歌名是下一个天亮,不过和这道题没什么关系。根据这两个例子猜测,需要两个辅助的方法,一个是交换,另一个是逆序。所以第一步的思路就是从后往前找,找一对儿符合要求的相邻数字。这道题的关键在于,找到规律,数学上的规律。 题目内容 给出一个数组,重新排列,返回『下一个排列,题目的描述中还给出了几个例子。 解决思路 有一首歌名是下一个天亮,不过和这道题没什么关系。还有一类题是已有一堆...

    dockerclub 评论0 收藏0
  • Binary Tree Upside Down LC解题记录

    摘要:题目内容因为这道题被锁住了,在写这篇文章时还有天就要过期了,把原题也贴上来。题目要求,树的结构是每个当右边子节点的,它肯定有个,就是它的根节点肯定有个左边子节点,也就是说它是二胎。递归设置终止条件,在空节点或最左边的叶子处终止。 题目内容 Given a binary tree where all the right nodes are either leaf nodes with a...

    Shonim 评论0 收藏0
  • [Leetcode] Strobogrammatic Number 对称数

    摘要:比如,先判断和是有映射的,然后和自己又是映射,所以是对称数。这样每次从中间插入两个对称的字符,之前插入的就被挤到两边去了。只插入一个字符时不能插入和插入字符和它的对应字符 Strobogrammatic Number I A strobogrammatic number is a number that looks the same when rotated 180 degrees ...

    wendux 评论0 收藏0

发表评论

0条评论

王晗

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<