当前位置:网站首页>Leetcode sword finger offer 17 Print from 1 to maximum n digits
Leetcode sword finger offer 17 Print from 1 to maximum n digits
2022-04-22 04:41:00 【Twilight rain forest bell】
Specific ideas :
Input number n, Print out from... In order 1 To the biggest n A decimal number . Such as input 3, Then print out 1、2、3 Up to the biggest 3 digit 999.
In the case of large numbers, you can directly calculate the large number of strings ;
Or arrange and combine ,dfs Breakable ;
Specific code :
class Solution {
public:
vector<int> printNumbers(int n) {
if(n <= 0) return vector<int>(0);
vector<int> res;
int num = 1;
for(int i=0; i<n; ++i)
num *= 10; // such as n=3,num Namely 1000
for(int i=1; i<num; ++i) res.push_back(i);
return res;
}
};
版权声明
本文为[Twilight rain forest bell]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220438342846.html
边栏推荐
- CommDGI: Community detection oriented deep graph infomax 2020 CIKM
- 10. Libevent receives and processes server messages
- POJ - 2456 Aggressive cows (二分 + 贪心)
- Memory model and namespace knowledge points summary
- 如何在 Bash 中将字符串计算为数字?
- 链表第四篇
- 树莓派4B编译paddlelite(详细步骤2022年)
- [concurrent programming 045] what is pseudo shared memory sequence conflict? How to avoid?
- 链表(Linked List)第一篇
- Matlab曲线的颜色、线型等参数设置方法
猜你喜欢

2022T电梯修理考试试题及在线模拟考试

2022T电梯修理考试练习题及在线模拟考试

SCI论文写作--IEEE期刊的Word模板(LaTeX也有)

Thread pool status + ThreadPoolExecutor

Will the expired data of redis be deleted immediately?

【S32K3_STM&PIT_MCAL】

2022 question bank and answers of Shandong Province safety officer C certificate special operation certificate examination

LeetCode 剑指 Offer 43. 1~n 整数中 1 出现的次数***

权威机构统计:2021 年最佳数据中心网络公司,中国华为和H3C上榜

2022年山东省安全员C证考试题及在线模拟考试
随机推荐
11.libevent对水平触发和边缘触发测试
Paper reading (48): a library of optimization algorithms for organizational design
JVM简记
10.libevent接收和处理服务器消息
DHCP protocol workflow
Revit data processing (III)
How expensive is the "salary" of software testing industry?
[concurrent programming 046] for the synchronization method, how does the processor realize atomic operation?
Crypto JS encryption algorithm library [installation tutorial, cache encryption]
Es next related
2022T电梯修理考试试题及在线模拟考试
MUI-弹出菜单
6_ Data analysis modeling
论文阅读 (47):DTFD-MIL: Double-Tier Feature Distillation Multiple Instance Learning for Histopathology..
目标检测--轻量级网络(截至2022-04-21)
2022 a special equipment related management (elevator) retraining question bank and answers
2022T电梯修理考试练习题及在线模拟考试
Linked list Chapter 4
树莓派4B编译paddlelite(详细步骤2022年)
爬演员名字加链接