[抄题]:

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. LA2572 Viva Confetti

    题意 PDF 分析 两两圆求交点,对每个圆弧按半径抖动. 时间复杂度\(O(T n^2)\) 代码 #include<iostream> #include<cstdio> #i ...

  2. C#如何动态设置屏幕分辨率

    C#如何动态设置屏幕分辨率 作者:Learning hard 这篇文章主要为大家详细介绍了C#动态设置屏幕分辨率的方法,我们可以使用Screen类设置屏幕分辨率,感兴趣的小伙伴们可以参考一下 下面就不 ...

  3. 从python爬虫引发出的gzip,deflate,sdch,br压缩算法分析

    今天在使用python爬虫时遇到一个奇怪的问题,使用的是自带的urllib库,在解析网页时获取到的为b'\x1f\x8b\x08\x00\x00\x00\x00...等十六进制数字,尝试使用chard ...

  4. bzoj 3566 [SHOI2014]概率充电器——树型

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3566 一眼看上去高斯消元.n^3不行. 竟然直接去看了TJ.发现树型dp.一下想到了自己还没 ...

  5. nginx虚拟主机的配置

    nginx虚拟主机的配置 server { listen ; server_name 127.0.0.1; access_log off; root /var/www/html/; location ...

  6. Git的其他一些使用案例

    按照格式输出提交号 作者 时间 git log --pretty=format:"%h %an %cd" --date=iso 获取所有远程的tag和他的commit sha1 g ...

  7. FIR滤波器和IIR滤波器的区别

    数字滤波器广泛应用于硬件电路设计,在离散系统中尤为常见,一般可以分为FIR滤波器和IIR滤波器,那么他们有什么区别和联系呢. FIR滤波器 定义: FIR滤波器是有限长单位冲激响应滤波器,又称为非递归 ...

  8. 全文检索引擎Solr系列——整合中文分词组件IKAnalyzer

    IK Analyzer是一款结合了词典和文法分析算法的中文分词组件,基于字符串匹配,支持用户词典扩展定义,支持细粒度和智能切分,比如: 张三说的确实在理 智能分词的结果是: 张三 | 说的 | 确实 ...

  9. zabbix增加手机短信、邮件监控的注意要点,SSL邮件发送python脚本

    1.短信接口文档: URL http://xxx.com/interfaces/sendMsg.htm Method POST Description 文字短信调用接口 Request Param L ...

  10. PL/SQL 训练09--面向对象

    ---对象基本声明.实现.使用--对象类型,类似与JAVA中的类,通俗的讲,就是捆绑了相关函数和过程的记录类型. ---对象声明 --create type 创建一个对象类型的规范部分 create ...