当前位置:网站首页>剑指 Offer 17. 打印从1到最大的n位数
剑指 Offer 17. 打印从1到最大的n位数
2022-06-30 16:53:00 【anieoo】

solution:
dfs,考虑大数
class Solution {
public:
vector<int> res;
string path;
vector<int> printNumbers(int n) {
dfs(n);
return res;
}
void dfs(int n) {
if(path.size() == n) {
int num = stoi(path);
if(num) res.push_back(num); //num不等于0才保存
return;
}
for(int i = 0;i < 10;i++) {
path.push_back(i + '0');
dfs(n);
path.pop_back();
}
}
};边栏推荐
- 每日面试1题-如何防止CDN防护被绕过
- Force deduction solution summary 1175- prime number arrangement
- 基于SSH的网上商城设计
- 分布式场景下,你知道有几种生成唯一ID的方式嘛?
- Small Tools(3) 集成Knife4j3.0.3接口文档
- 100 examples of bug records of unity development (the first example) -- shader failure or bug after packaging
- 漏洞复现----37、Apache Unomi 远程代码执行漏洞 (CVE-2020-13942)
- Hcip (Huawei Senior Network Security Engineer) (Experiment 8) (MPLS basic experiment)
- Deep understanding of JVM (V) - garbage collection (II)
- Exploration and practice of "flow batch integration" in JD
猜你喜欢

Oneortwo bugs in "software testing" are small things, but security vulnerabilities are big things. We must pay attention to them

News management system based on SSM

Redis (VII) - sentry

4 years of working experience, and you can't tell the five communication modes between multithreads. Can you believe it?

元宇宙带来的游戏变革会是怎样的?

DeFi借贷协议机制对比:Euler、Compound、Aave和Rari Capital

If you want to learn software testing, you must see series, 2022 software testing engineer's career development

K-line diagram interpretation and practical application skills (see position entry)

MySQL advanced - basic index and seven joins

每日面试1题-如何防止CDN防护被绕过
随机推荐
Distributed machine learning: model average Ma and elastic average easgd (pyspark)
[bjdctf2020]the mystery of ip|[ciscn2019 southeast China division]web11|ssti injection
又一篇CVPR 2022论文被指抄袭,平安保险研究者控诉IBM苏黎世团队
MIT科技评论2022年35岁以下创新者名单发布,含AlphaFold作者等
巴比特 | 元宇宙每日必读:未成年人打赏后要求退款,虚拟主播称自己是大冤种,怎么看待这个监管漏洞?...
.NET ORM框架HiSql实战-第一章-集成HiSql
分布式场景下,你知道有几种生成唯一ID的方式嘛?
Ardunio esp32 obtains real-time temperature and humidity in mqtt protocol (DH11)
Redis (I) - data type
Solve the problem of unable to connect to command metric stream and related problems in the hystrix dashboard
K-line diagram interpretation and practical application skills (see position entry)
联想“双平台”运维解决方案 助力智慧医疗行业智慧管理能力全面提升
Vs Code treeview TreeView
Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, is building an open source ecological road
同济、阿里的CVPR 2022最佳学生论文奖研究了什么?这是一作的解读
Partition marble (multiple knapsack + binary optimization)
5g has been in business for three years. Where will innovation go in the future?
IEEE TBD SCI impact factor increased to 4.271, ranking Q1!
Elastic 8.0: opening a new era of speed, scale, relevance and simplicity
Dropout: immediate deactivation