当前位置:网站首页>剑指 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();
}
}
};边栏推荐
- Type ~ storage ~ variable in C #
- .NET ORM框架HiSql实战-第一章-集成HiSql
- Compile and generate busybox file system
- Distributed machine learning: model average Ma and elastic average easgd (pyspark)
- 【二叉树】前序遍历构造二叉搜索树
- 腾讯云安装mysql数据库
- 巴比特 | 元宇宙每日必读:未成年人打赏后要求退款,虚拟主播称自己是大冤种,怎么看待这个监管漏洞?...
- News management system based on SSM
- [Netease Yunxin] playback demo build: unable to convert parameter 1 from "asyncmodalrunner *" to "std:: nullptr\u T"**
- Conception d'un centre commercial en ligne basé sur SSH
猜你喜欢

零基础也能做Apple大片!这款免费工具帮你渲染、做特效、丝滑展示

助力极致体验,火山引擎边缘计算最佳实践

TFTP download kernel, NFS mount file system

基于eNSP的校园网设计的仿真模拟

Redis (I) - data type

Exploration and practice of "flow batch integration" in JD

MySQL advanced - Architecture

Deep understanding of JVM (V) - garbage collection (II)

vue3 响应式数据库—— reactive

Oneortwo bugs in "software testing" are small things, but security vulnerabilities are big things. We must pay attention to them
随机推荐
Send the injured baby for emergency medical treatment. Didi's driver ran five red lights in a row
MIT science and Technology Review released the list of innovators under the age of 35 in 2022, including alphafold authors, etc
Redis (VI) - master-slave replication
力扣解法汇总1175-质数排列
Flutter custom component
阿里云ECS导入本地,解决部署的问题
Sign up for Huawei cloud proposition in the "Internet +" competition, and you can take many gifts!
Customer relationship CRM management system based on SSH
What should I pay attention to when playing futures? Where is safe to open an account? It's my first contact
Daily interview 1 question - basic interview question of blue team - emergency response (1) basic idea process of emergency response +windows intrusion screening idea
Word中添加代码块(转载)
ASP. Net password encryption and password login
Radio and television 5g officially set sail, attracting attention on how to apply the golden band
MSF后渗透总结
Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, is building an open source ecological road
每日面试1题-如何防止CDN防护被绕过
Lenovo's "dual platform" operation and maintenance solution helps to comprehensively improve the intelligent management ability of the intelligent medical industry
腾讯云安装mysql数据库
火山引擎入选国内首个《边缘计算产业全景图》
Php8.0 environment detailed installation tutorial