当前位置:网站首页>Sword finger offer 17 Print from 1 to maximum n digits
Sword finger offer 17 Print from 1 to maximum n digits
2022-06-30 18:28:00 【anieoo】
Original link : The finger of the sword Offer 17. Print from 1 To the biggest n digit
solution:
dfs, Consider large numbers
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 It's not equal to 0 Just save
return;
}
for(int i = 0;i < 10;i++) {
path.push_back(i + '0');
dfs(n);
path.pop_back();
}
}
};
边栏推荐
- Tensorflow2 ten must know for deep learning
- Rust 书籍资料 - 芽之家书馆
- Deep understanding of JVM (III) - memory structure (III)
- Optimize with netcorebeauty Net core independent deployment directory structure
- Development and construction of NFT mining tour gamefi chain tour system
- Deep understanding of JVM (IV) - garbage collection (I)
- 基于SSM的新闻管理系统
- Daily interview 1 question - basic interview question of blue team - emergency response (1) basic idea process of emergency response +windows intrusion screening idea
- Redis (II) -- persistence
- What will be the game changes brought about by the meta universe?
猜你喜欢
Do you write API documents or code first?
Redis (V) - advanced data types
[software testing] basic knowledge of software testing you need to know
What does software testing need to learn? Test learning outline sorting
Design of online shopping mall based on SSH
[PROJECT] Xiaomao school (IX)
腾讯持久化框架MMKV原理探究
Vulnerability recurrence ----37. Apache unomi Remote Code Execution Vulnerability (cve-2020-13942)
Dropout: immediate deactivation
助力极致体验,火山引擎边缘计算最佳实践
随机推荐
云安全日报220630:IBM数据保护平台发现执行任意代码漏洞,需要尽快升级
Redis (IX) - enterprise level solution (II)
Zero foundation can also be an apple blockbuster! This free tool can help you render, make special effects and show silky slides
Rainbow Brackets 插件的快捷键
力扣解法汇总1175-质数排列
Rhai 脚本引擎的简单应用示例
Ardunio esp32 DH11 real time uploading temperature and humidity Alibaba cloud self built mqtt
漏洞复现----35、uWSGI PHP 目录遍历漏洞 (CVE-2018-7490)
VScode 状态条 StatusBar
News management system based on SSM
元宇宙带来的游戏变革会是怎样的?
国内离线安装 Chrome 扩展程序的方法总结
Optimization of interface display for general kernel upgrade of mobo video management system v3.5.0
Openlayers roller shutter map
使用excel快速生成sql语句
Advanced embedded application of uni app [day14]
C语言结构体
分布式场景下,你知道有几种生成唯一ID的方式嘛?
Unity开发bug记录100例子(第1例)——打包后shader失效或者bug
Deep understanding of JVM (V) - garbage collection (II)