<> Interview questions 17. Print from 1 To the largest n digit

Enter number n, Print out from 1 To the largest n Decimal number . For example, 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 Is a positive integer

<> Solving problems 1

Over and over again , The idea is very simple as follows ( But after that , Read the explanation , It is said that the title in the original book is not so simple , It's a big number problem ):

1, Splicing n individual 9
2,new One n individual 9 Array of
3, Traverse once , Insert data

class Solution { static public int[] printNumbers(int n) { String str = ""; for
(int i = 0; i < n; i++) { str = str +"9"; } int[] ints = new int[Integer.valueOf
(str)]; for (int i = 0; i < ints.length; i++) { ints[i] = i+1; } return ints; }
public static void main(String[] args) { int[] ints = printNumbers(3); for (int
i= 0; i < ints.length; i++) { System.out.print(ints[i]+","); } } }

Technology
©2019-2020 Toolsou All rights reserved,
" Cephalosporin wine Say go and go "? DANGER ! Don't drink alcohol when taking these drugs Programmer Tanabata Valentine's Day confession code China Lunar Rover “ Moon rabbit No.2 ” A strange rock was found on the moon use C++ I want to talk to you “ Prototype mode ” ( copy / copy constructor ) Software testing BUG describe Random forest R Language implementation TP6 Application examples of verifier and correct verification data Google says home office affects work efficiency !2021 Return to offline office in 2010 Message quality platform series | Full link troubleshooting Free download of documents : To introduce you to a few useful free download URL