[抄题]:
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.
[暴力解法]:
时间分析:
空间分析:
[优化后]:
时间分析:
空间分析:
[奇葩输出条件]:
[奇葩corner case]:
[思维问题]:
class Solution { public boolean isStrobogrammatic(String num) { //cc if (num == null || num.length() == 0) { return true; } //for loop for (int i = 0, j = num.length() - 1; i <= j ; i++, j --) { if (!"11 00 88 69 96".contains(num.charAt(i) + "" + num.charAt(j))) return false; } return true; } }
不知道对称性怎么处理:两个指针啊!
[一句话思路]:
抽出来之后看字符串中是否互相包含
[输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不合理的输入):
[画图]:
[一刷]:
[二刷]:
[三刷]:
[四刷]:
[五刷]:
[五分钟肉眼debug的结果]:
[总结]:
判断字符串对称 用对撞型指针
[复杂度]:Time complexity: O(n) Space complexity: O(1)
[英文数据结构或算法,为什么不用别的数据结构或算法]:
[关键模板化代码]:
[其他解法]:
[Follow Up]:
247. Strobogrammatic Number II 找出所有两位的:递归,好吧
[LC给出的题目变变变]:
[代码风格] :