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

Find all strobogrammatic numbers that are of length = n.

For example,
Given n = 2, return ["11","69","88","96"].

 class Solution {
public:
char num[] = {'', '', '', '', ''};
char rotate(char num) {
if (num == '' || num == '' || num == '')
return num;
else if (num == '') return '';
else return '';
}
void help(vector<string>& res, string& cand, int curInd) {
if (cand.size() & && curInd == (cand.size() - ) / ) {
cand[curInd] = ''; res.push_back(cand);
cand[curInd] = ''; res.push_back(cand);
cand[curInd] = ''; res.push_back(cand);
} else {
int st = curInd ? : ;
for (; st < ; st++) {
cand[curInd] = num[st];
cand[cand.size() - curInd - ] = rotate(num[st]);
if (curInd == (cand.size() - ) / ) res.push_back(cand);
else help(res, cand, curInd + );
}
}
}
vector<string> findStrobogrammatic(int n) {
vector<string> res;
if (n < ) return res;
string cand(n, '');
help(res, cand, );
return res;
}
};

Strobogrammatic Number II -- LeetCode的更多相关文章

  1. [Locked] Strobogrammatic Number & Strobogrammatic Number II & Strobogrammatic Number III

    Strobogrammatic Number A strobogrammatic number is a number that looks the same when rotated 180 deg ...

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

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

  3. LeetCode Strobogrammatic Number II

    原题链接在这里:https://leetcode.com/problems/strobogrammatic-number-ii/ 题目: A strobogrammatic number is a n ...

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

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

  5. [LeetCode#247] Strobogrammatic Number II

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

  6. 247. Strobogrammatic Number II

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

  7. [Swift]LeetCode247.对称数 II $ Strobogrammatic Number II

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

  8. 247. Strobogrammatic Number II输出所有对称数字

    [抄题]: A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at u ...

  9. Ugly Number II leetcode java

    问题描述: Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime fa ...

随机推荐

  1. .netCore 反射 :Could not load file or assembly 系统找不到指定文件

    “System.IO.FileNotFoundException:“Could not load file or assembly 'ClassLibrary2, Culture=neutral, P ...

  2. Android 启动项 Activity

    使用SDK创建一个App的时候,基本都会看到这段代码: <activity android:name=".ExampleActivity" android:icon=&quo ...

  3. 关于jdk与jre的区别

    JDK:Java Development Kit JRE顾名思义是java运行时环境,包含了java虚拟机,java基础类库.是使用java语言编写的程序运行所需要的软件环境,是提供给想运行java程 ...

  4. 【Python】- yield 使用浅析

    您可能听说过,带有 yield 的函数在 Python 中被称之为 generator(生成器),何谓 generator ? 我们先抛开 generator,以一个常见的编程题目来展示 yield ...

  5. InfluxDB执行语句管理(query management)

    本文属于<InfluxDB系列教程>文章系列,该系列共包括以下 17 部分: InfluxDB学习之InfluxDB的基本概念 InfluxDB学习之InfluxDB的基本操作 Influ ...

  6. linux fg bg ctrl + z jobs & 等命令

    fg.bg.jobs.&.ctrl + z都是跟系统任务有关的,虽然现在基本上不怎么需要用到这些命令,但学会了也是很实用的一.& 最经常被用到这个用在一个命令的最后,可以把这个命令放到 ...

  7. 开启和关闭mysql服务

    @echo offfor /f "skip=3 tokens=4" %%i in ('sc query MySQLa') do set "zt=%%i" &am ...

  8. display:inline、block、inline-block的区别 摘】

    display:block就是将元素显示为块级元素. block元素的特点是: 总是在新行上开始: 高度,行高以及顶和底边距都可控制: 宽度缺省是它的容器的100%,除非设定一个宽度 <div& ...

  9. 使用 padding-bottom 设置高度基于宽度的自适应

    我们在做移动端列表,通常会做到图文列表,列表是自适应的.当列表中有图片,图片的宽度是随着列表宽的变化而变化,我们为了在图片宽度变化的时候做到图片的不变形,所有采用以下办法. 本文章只讲语法 html ...

  10. malloc,calloc,realloc区别

    malloc:memory allocation calloc:The 'c' indicates 'cleared' realloc:The realloc() function changes t ...