Strobogrammatic Number
https://leetcode.com/problems/strobogrammatic-number/description/
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.
Thoughts
检查一串数字是否满足翻180°还是原来的数字。 和回文一样必须两边对称,不同的是这次6和9是对称的,0, 8, 1分别和对应的相同数字对称,并且中间的数也只能是它们仨。
Code
Analysis
时间复杂度O(N)
Last updated
Was this helpful?