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?