[抄题]:

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. linux rhel7下安装python

    1.查看是否已经安装Python Centos7默认安装了python2.7.5 因为一些命令要用它比如yum 它使用的是python2.7.5. 使用python -V命令查看一下是否安装Pytho ...

  2. verilog数组定义及其初始化

    这里的内存模型指的是内存的行为模型.Verilog中提供了两维数组来帮助我们建立内存的行为模型.具体来说,就是可以将内存宣称为一个reg类型的数组,这个数组中的任何一个单元都可以通过一个下标去访问.这 ...

  3. 设置正确的DNS

    上网或下载软件慢问题,除去少数设备陈旧.感染病毒.网卡硬件故障和网卡驱动错误方面的因素,绝大部分原因是由于部分上网电脑或家用无线路由器设置了错误的DNS造成的,正确的方法是应该在电脑或路由器上使用本地 ...

  4. java的内存管理 对象的分配与释放

    分配 程序员通过new为每个对象申请内存空间(基本类型除外),所有对象都在堆中分配空间:释放:对象的释放是由垃圾回收机制决定和执行的. Java内存分为两种:栈内存和堆内存 (1)在函数中定义的基本类 ...

  5. Markdown 中的目录自动生成功能 TOC

    目录 Markdown 中的目录自动生成功能 TOC 1. 标题一 1.1 标题二 1.标题二 2. 标题一 2.1 标题二 2.2 标题二 Markdown 中的目录自动生成功能 TOC 1. 标题 ...

  6. sed 相关

    sed中,a命令是指在匹配的位置后面插入新的内容. c命令是说将在匹配模式空间的指定行用新文本加以替代.

  7. MySQL模式匹配(LIKE VS REGEXP)

    3.3.4.7. 模式匹配 MySQL提供标准的SQL模式匹配,以及一种基于象Unix实用程序如vi.grep和sed的扩展正则表达式模式匹配的格式. SQL模式匹配允许你使用“_”匹配任何单个字符, ...

  8. java代码关于匿名内部类和接口的方法使用

    总结:主要是多个按钮实现监听时,能够响应不同的事件 以上步骤我们可以用多种方法实现.但人们通常用二种方法.第一种方法是只利用一个监听器以及多个if语句来决定是哪个组件产生的事件:第二种方法是使用多个内 ...

  9. Java-API-Package:java.net百科

    ylbtech-Java-API-Package:java.net百科 并非所有系统都支持 IPv6 协议,而当 Java 网络连接堆栈尝试检测它并在可用时透明地使用它时,还可以利用系统属性禁用它.在 ...

  10. PHP 统计数据功能 有感

    统计,就是把基本的数据,整合起来. 用到sql的,有group by 功能,count功能,order by功能等等. sql将收集的数据,进行统计分析. 一般情况下,sql处理后得到的数据,还要通过 ...