当前位置:网站首页>剑指 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();
}
}
};边栏推荐
- Fragmentary knowledge points of MySQL
- 阿里云ECS导入本地,解决部署的问题
- Simulation of campus network design based on ENSP
- 力扣解法汇总1175-质数排列
- What should I pay attention to when playing futures? Where is safe to open an account? It's my first contact
- Generate confrontation network, from dcgan to stylegan, pixel2pixel, face generation and image translation.
- MySQL advanced - Architecture
- Distributed machine learning: model average Ma and elastic average easgd (pyspark)
- . Net ORM framework hisql practice - Chapter 1 - integrating hisql
- Redis (II) -- persistence
猜你喜欢

MIT科技评论2022年35岁以下创新者名单发布,含AlphaFold作者等

Deep understanding of JVM (VI) -- garbage collection (III)

Compile and generate busybox file system

ABAP publish restful service

Generate confrontation network, from dcgan to stylegan, pixel2pixel, face generation and image translation.

基于SSH的通讯网络电子计费系统

Redis (II) -- persistence

Deep understanding of JVM (III) - memory structure (III)

K-line diagram must be read for quick start

墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
随机推荐
Flutter custom component
TCP session hijacking based on hunt1.5
Zero foundation can also be an apple blockbuster! This free tool can help you render, make special effects and show silky slides
Design and principle of tubes responsive data system
uni-app进阶之自定义【day13】
Simulation of campus network design based on ENSP
[binary tree] preorder traversal to construct binary search tree
Redis (I) - data type
leetcode:787. The cheapest transfer flight in station K [k-step shortest path + DFS memory + defaultdict (dict)]
腾讯云安装mysql数据库
Daily interview 1 question - how to prevent CDN protection from being bypassed
Servlet operation principle_ API details_ Advanced path of request response construction (servlet_2)
ASP. Net generate verification code
墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
零基础也能做Apple大片!这款免费工具帮你渲染、做特效、丝滑展示
Distributed machine learning: model average Ma and elastic average easgd (pyspark)
Type ~ storage ~ variable in C #
Force deduction solution summary 1175- prime number arrangement
K-line diagram must be read for quick start
基於SSH的網上商城設計