[LeetCode]剑指 Offer 17. 打印从1到最大的n位数

数据库93

输入数字 n,按顺序打印出从 1 到最大的 n 位十进制数。比如输入 3,则打印出 1、2、3 一直到最大的 3 位数 999。

示例 1:

输入: n = 1
输出: [1,2,3,4,5,6,7,8,9]

说明:

  • 用返回一个整数列表来代替打印
  • n 为正整数

来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/da-yin-cong-1dao-zui-da-de-nwei-shu-lcof
版权归领扣网络所有。商业转载,请联系官方授权。非商业性转载,请注明出处。

[En]

The copyright belongs to the collar and buckle network. For commercial reprint, please contact official authorization. For non-commercial reprint, please indicate the source.

```csharp
public class Solution {
public int[] PrintNumbers(int n) {
int len = (int)Math.Pow(10, n) - 1;

输入验证码查看隐藏内容

扫描二维码关注本站微信公众号 Johngo学长
或者在微信里搜索 Johngo学长
回复 svip 获取验证码
wechat Johngo学长