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. 每天一个Linux命令(2):shutdown命令

    shutdown命令是系统关机命令.shutdown指令可以关闭所有程序,并依用户的需要,进行重新开机或关机的动作. 语法 shutdown(选项)(参数) 选项 -c:取消已经在进行的 shutdo ...

  2. 巧用Fiddler代理来禁止资源缓存,从而达到每次都是从服务器加载最新的资源

    Fiddler ->  Rules ->  Performance  -> Disable Caching 直接设置禁用缓存,再在没有清除缓存功能的APP 中重新加载最新的页面, 每 ...

  3. STL之set&multiset使用简介

    关于set,必须说明的是set关联式容器.set作为一个容器也是用来存储同一数据类型的数据类型,并且能从一个数据集合中取出数据,在set中每个元素的值都唯一,而且系统能根据元素的值自动进行排序.应该注 ...

  4. 集训队日常训练20181124 DIV2

    急急忙忙要出去比赛就拉了一场有点sb的题目 5202: 网络寻路  时间限制(普通/Java):1000MS/3000MS     内存限制:65536KByte总提交: 15            ...

  5. Servlet 中 RequestDispacher 请求与分发

    RequestDispacher 请求与分发使用HttpServletRequest的getRequestDispatcher()方法取得 Login.java页面 package control; ...

  6. 201621123034 《Java程序设计》第7周学习总结

    作业07-Java GUI编程 1. 本周学习总结 1.1 思维导图:Java图形界面总结 1.2 可选:使用常规方法总结其他上课内容. 2.书面作业 1. GUI中的事件处理 1.1 写出事件处理模 ...

  7. 201621123033 《Java程序设计》第10周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常相关内容. 2. 书面作业 本次PTA作业题集异常 1. 常用异常 结合题集题目7-1回答 1.1 自己以前编写的代码中经常出现 ...

  8. PHP实现图片上传并压缩

    本文实例讲解了PHP图片上传并压缩的实现方法,分享给大家供大家参考,具体内容如下 使用到三个文件 connect.php:连接数据库 test_upload.php:执行SQL语句 upload_im ...

  9. 湘潭邀请赛 2018 E From Tree to Graph

    题意: 给出一棵树以及m,a,b,x0,y0.之后加m条边{(x1,LCA(x1,y1)),(x2,LCA(x2,y2))...(xm,LCA(xm,ym))}.定义z = f(0)^f(1)^... ...

  10. Educational Codeforces Round 2 A. Extract Numbers

    打开题目链接 题意:输入一个字符串,用,或:分隔输出字符串和整数(不含前导0和浮点数) ACcode: #include <iostream> #include <cstdio> ...