[抄题]:

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. TCP, Scoket, HTTP(转)

    1.TCP连接 要想明白Socket连接,先要明白TCP连接.手机能够使用联网功能是因为手机底层实现了TCP/IP协议,可以使手机终端通过无线网络建立TCP连接.TCP协议可以对上层网络提供接口,使上 ...

  2. IQ信号理解

    可参考http://wenku.baidu.com/link?url=Y3plyK9lgl96QowljJkWhgVaUGbH11j178DkId_vcl9z1V5cjl9ycTiB4Ym4iaypL ...

  3. 十七、python沉淀之路--三元表达式、列表解析

    一.三元表达式 a = '骑车' res = '好天气' if a == '骑车' else '睡觉' print(res) 睡觉 解析:res = '好天气'        if a == '骑车' ...

  4. Visual Studio Code教程:基础使用和自定义设置

    一.界面介绍 1.1 界面介绍 1.2 文件夹和文件的打开 文件——>打开文件夹/打开文件 1.3 新建文件/文件夹 新建文件: a. 文件——>新建文件: b. 按Ctrl+n; c. ...

  5. 前端后端json技术整理

    前端: json对象,例如 var data = { c:, person:[ {name:}, {name:}, {name:}, {name:}, {name:} ] }; 转化为,json串 J ...

  6. log框架集成

    使用slf4j,slf4j相当于一个接口,我们面对接口编程,方便地集成其他的日志框架,我们按照slf4j的标准,日志就会相应地打入日志系统中(log4j 使用slf4j要有两个包1,他本身的api,2 ...

  7. linux 查看系统信息和安装哪些软件的命令

    https://www.cnblogs.com/wangkongming/p/4531341.html 查看系统磁盘硬盘占用率 https://blog.csdn.net/aaashen/articl ...

  8. mysql导入导出表结构

    mysql导入导出表结构 导出整个库的表结构如下:mysqldump -uroot -p -d databasename > createtab.sql 如果只想导出表: test1,test2 ...

  9. Linux安装JRE tomcat配置java环境

    安装JRE 到http://www.oracle.com/technetwork/java/javase/downloads/index.html下载JRE软件. 1.wget http://down ...

  10. 怎么样使用yum来安装mysql

    linux下使用yum安装mysql,以及启动.登录和远程访问. 1.安装 查看有没有安装过: yum list installed mysql* rpm -qa | grep mysql* 查看有没 ...