当前位置:网站首页>剑指 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();
}
}
};边栏推荐
- vue3 响应式数据库—— reactive
- Nielseniq welcomes dawn E. Norvell, head of retail lab, to accelerate the expansion of global retail strategy
- MIT科技评论2022年35岁以下创新者名单发布,含AlphaFold作者等
- uni-app进阶之自定义【day13】
- 【云驻共创】Huawei iConnect使能物联终端一触即联
- Redis (VIII) - enterprise level solution (I)
- 5g has been in business for three years. Where will innovation go in the future?
- Php8.0 environment detailed installation tutorial
- Lenovo's "dual platform" operation and maintenance solution helps to comprehensively improve the intelligent management ability of the intelligent medical industry
- Tencent cloud installs MySQL database
猜你喜欢

News management system based on SSM

vue3 响应式数据库—— reactive

Radio and television 5g officially set sail, attracting attention on how to apply the golden band

清华只能排第3?2022软科中国大学AI专业排名发布

分布式场景下,你知道有几种生成唯一ID的方式嘛?

K-line diagram must be read for quick start

Animesr: learnable degradation operator and new real world animation VSR dataset

MIT science and Technology Review released the list of innovators under the age of 35 in 2022, including alphafold authors, etc

Design of online shopping mall based on SSH

autocad中文语言锁定只读警报怎么解决?
随机推荐
The company was jailed for nonstandard bug during the test ~ [cartoon version]
Simulation of campus network design based on ENSP
联想“双平台”运维解决方案 助力智慧医疗行业智慧管理能力全面提升
If you want to learn software testing, you must see series, 2022 software testing engineer's career development
【机器学习】K-means聚类分析
力扣解法汇总1175-质数排列
It's not easy to say I love you | use the minimum web API to upload files
What did Tongji and Ali study in the CVPR 2022 best student thesis award? This is an interpretation of yizuo
100 examples of bug records of unity development (the first example) -- shader failure or bug after packaging
2022上半年盘点:20+主流数据库重大更新及技术要点汇总
又一篇CVPR 2022论文被指抄袭,平安保险研究者控诉IBM苏黎世团队
Ardunio esp32 DH11 real time uploading temperature and humidity Alibaba cloud self built mqtt
Conception d'un centre commercial en ligne basé sur SSH
Hcip (Huawei Senior Network Security Engineer) (Experiment 8) (MPLS basic experiment)
What does software testing need to learn? Test learning outline sorting
How to write a technical proposal
Talk about the SQL server version of DTM sub transaction barrier function
vue3 响应式数据库—— reactive
MySQL reports that the column timestamp field cannot be null
分布式场景下,你知道有几种生成唯一ID的方式嘛?