当前位置:网站首页>Sword finger offer 17 Print from 1 to the maximum n digits
Sword finger offer 17 Print from 1 to the maximum n digits
2022-07-03 12:59:00 【Hiccup~~~~】
The finger of the sword Offer 17. Print from 1 To the biggest n digit
The difficulty is simple 229 Switch to English to receive dynamic feedback
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.
Example 1:
Input : n = 1 Output : [1,2,3,4,5,6,7,8,9]
explain :
- Instead of printing, return a list of integers
- n As a positive integer
Code
class Solution {
public:
vector<int> printNumbers(int n) {
vector<int> res(pow(10,n)-1);
for(int i=1;i<=pow(10,n)-1;i++){
res[i-1]=i;
}
return res;
}
};
边栏推荐
- 剑指 Offer 11. 旋转数组的最小数字
- Application of ncnn neural network computing framework in orange school orangepi 3 lts development board
- GaN图腾柱无桥 Boost PFC(单相)七-PFC占空比前馈
- GCN thinking - word2vec directly calculates text classification
- Xctf mobile--app3 problem solving
- [problem exploration and solution of one or more filters or listeners failing to start]
- [ArcGIS user defined script tool] vector file generates expanded rectangular face elements
- Drop down refresh conflicts with recyclerview sliding (swiperefreshlayout conflicts with recyclerview sliding)
- 初入职场,如何快速脱颖而出?
- Xctf mobile--app1 problem solving
猜你喜欢
Day 1 of kotlin learning: simple built-in types of kotlin
Social community forum app ultra-high appearance UI interface
基于同步坐标变换的谐波电流检测
Xctf mobile--app3 problem solving
01 three solutions to knapsack problem (greedy dynamic programming branch gauge)
Glide question you cannot start a load for a destroyed activity
Leetcode234 palindrome linked list
【数据库原理及应用教程(第4版|微课版)陈志泊】【SQLServer2012综合练习】
Solve the problem of VI opening files with ^m at the end
initial、inherit、unset、revert和all的区别
随机推荐
【习题六】【数据库原理】
initial、inherit、unset、revert和all的区别
Four problems and isolation level of MySQL concurrency
剑指 Offer 14- II. 剪绳子 II
Low code platform international multilingual (I18N) technical solution
最新版抽奖盲盒运营版
Export the entire Oracle Database
【数据挖掘复习题】
ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹
Sword finger offer14 the easiest way to cut rope
The upward and downward transformation of polymorphism
Gan totem column bridgeless boost PFC (single phase) seven PFC duty cycle feedforward
Define a list, store n integers, and calculate the length, maximum value, minimum value and average value of the list
剑指 Offer 17. 打印从1到最大的n位数
Xctf mobile--rememberother problem solving
[Exercice 5] [principe de la base de données]
Dojo tutorials:getting started with deferrals source code and example execution summary
剑指 Offer 15. 二进制中1的个数
基于同步坐标变换的谐波电流检测
The foreground uses RSA asymmetric security to encrypt user information