In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how leetCode prints from 1 to the largest n-digit number. I hope you will get something after reading this article. Let's discuss it together.
First, print from 1 to the maximum number of n digits 1, a brief description of the problem
Enter the number n and print out the n-digit decimal number from 1 to the largest n digits in order. For example, enter 3, then print out 1, 2, 3 all the way up to the maximum 3 digits 999.
2, example description example 1:
Input: n = 1
Output: [1, 2, 3, 4, 5, 6, 7, 8, 9]
Description:
Instead of printing, return a list of integers
N is a positive integer
3, the train of thought of solving the problem
Calculate the data of 10 ^ n, and then use the array to load the data
4, problem solving program public class PrintNumberTest {
Public static void main (String [] args) {
Int nasty 1
Int [] printNumbers = printNumbers (n)
For (int num:printNumbers
) {
System.out.print (num+ "\ t")
}
}
Public static int [] printNumbers (int n) {
If (n = = 0) {
Return new int [] {0}
}
Double length = Math.pow (10, n)-1
Int [] result=new int [(int) length]
For (int I = 0; I
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.