[抄题]:

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给出的题目变变变]:

[代码风格] :

246. Strobogrammatic Number 上下对称的数字的更多相关文章

  1. LeetCode 246. Strobogrammatic Number (可颠倒数字) $

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

  2. [LeetCode] 246. Strobogrammatic Number 对称数

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

  3. [LeetCode] 247. Strobogrammatic Number II 对称数II

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

  4. [LeetCode] 248. Strobogrammatic Number III 对称数III

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

  5. [LeetCode] Strobogrammatic Number II 对称数之二

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

  6. [LeetCode] Strobogrammatic Number III 对称数之三

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

  7. [LeetCode] 248. Strobogrammatic Number III 对称数之三

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

  8. 【LeetCode】246. Strobogrammatic Number 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典 日期 题目地址:https://leetcode ...

  9. 246. Strobogrammatic Number

    题目: A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at ups ...

随机推荐

  1. iOS AnchorPoint 引起的坐标问题

    这里主要讨论设置AnchorPoint 改变时,会影响我们预期的布局问题: 一.初始代码布局     //参照页面     UIView *aView = [[UIView alloc]initWit ...

  2. 转载.Avalon-MM 阿窝龙妹妹应用笔记

    Avalon Interface Special http://www.altera.com.cn/literature/manual/mnl_avalon_spec.pdf Avalon总线是SOP ...

  3. 支付宝RSA签名

    1.参考网上相关文章,开放php中的openssl,但使用网上例子调用openssl_pkey_new,一直报100013错误.后改用用支付宝提供的SDKdemo程序 发现使用提供的privkye,可 ...

  4. xmldoc

    vmsConfig.js var loadXML = function(xmlString) { // 构建xmldoc对象 var xmlDoc = null; if (window.DOMPars ...

  5. Python 字典 列表 嵌套 复杂排序大全

    https://blog.csdn.net/ray_up/article/details/42084863 一: 字典排序 解析: 使用sorted 方法, 排序后的结果为一个元组. 可以字符串排序( ...

  6. 在 windows7 中使用 vs2003 时,“在文件中查找”导致无响应的问题

    解决 Win7 32bit/64bit环境下,在使用VS2003的查找功能时,会导致VS2003无响应. 解决方法:找到VS2003的安装目录,修改"...\Microsoft Visual ...

  7. maven环境配置详解,及maven项目的搭建及maven项目聚合

    首先:Maven 3.2.1:不同版本中仓库中文件是不一样的,Maven运行,先找用户配置,再找全局配置 1. Maven全局配置:全局统一的配置文件,在maven的安装目录中 2. Maven用户配 ...

  8. linux启动自动挂载分区和/etc/fstab简单修复

    让后加的分区能够启动时自动挂载,需要把配置写入文件 /etc/fstab vi /etc/fstab UUID=3f5859e0-592f-42cd-b533-570422fb85be   / ext ...

  9. 【转】JMeter脚本的参数化

    JMeter脚本的参数化 当你利用Badboy将你的测试脚本录制完毕后,接下来就是脚本的调试工作了.在我看来,调试应该包括有以下几个方面:1.根据测试场景对脚本进行必要的修改:2.脚本参数化:3.添加 ...

  10. PL/SQL 训练08--触发器

    --什么是触发器呢?--一触即发,某个事件发生时,执行的程序块?--数据库触发器是一个当数据库发生某种事件时作为对这个事件的响应而执行的一个被命名的程序单元 --适合场景--对表的修改做验证--数据库 ...