Hello everyone, I am quick-frozen fish 🐟, a water front 💦, like the garish 💐, continuous sand sculpture 🌲 Welcome friends to add my wechat: Sudongyuer pull you into the group of my public number: front-end quick-frozen fish progress together, looking forward to growing together with everyone

Preface 🌧 ️

Algorithms are unfamiliar and familiar to the front-end people, and often we don’t value them as much as the back-end engineers do. But in fact, algorithms have an unshakable position for every programmer.

Because the development process is to convert the actual problem into the computer can recognize the instructions, that is, “data structure” said, “design the data structure, in the application of algorithms on the line”.

Of course, learning is also focused, as the front end we do not need to fully grasp the algorithm like back-end development, some of the more partial, not practical type and solution method, as long as a little understanding.

The title 🦀

17. Print n digits from 1 to maximum

Difficulty is simple

Enter the number n to print out the largest n decimal digits in sequence. For example, if you type 3, you print 1, 2, 3 up to 999.

Example 1:

Input: n = 1 Output: [1,2,3,4,5,6,7,8,9]Copy the code

Description:

  • Return a list of integers instead of printing
  • N is a positive integer

🌵

  • The largest number of n digits is 10^n-1, which can be output in a loop without considering large numbers.

Source 🔥

/ * * *@param {number} n
 * @return {number[]}* /
var printNumbers = function(n) {
    let result=[]
    for(let i=1; i<=Math.pow(10,n)-1; i++){ result.push(i) }return result
};
Copy the code

Time complexity: O(10^n)

Space complexity: O(1)

Conclusion 🌞

So the “LeetCode” of Yuyu LeetCode algorithm refers to the end of the offer-17 printing from 1 to the largest n digits ⚡️. There is no shortcut to algorithm, only to write and practice more, and summarize more. The purpose of the article is actually very simple, is to urge myself to complete algorithm practice and summarize and output, dishes are not important. But I love 🔥, and I like that everyone can like my essay, and I also hope to know more like-minded friends through the article. If you also like to toss, welcome to add my friend, sand sculpture together, and progress together.

Making 🤖 : sudongyu

Personal blog 👨💻: Frozen fish blog

Vx 👦 : sudongyuer

Write in the last

Guys, if you like my words, give 🐟🐟 a thumbs up 👍 or follow ➕ to support me the most.

Add me on wechat: Sudongyuer, invite you into the group and learning the front together, become a better engineer ~ (group of qr code here – > front to go to bed early, qr code has expired, see the links to the boiling point in the comments, I will put the latest qr code in the comments section, of course, can also add me WeChat I pull you into the group, after all, I also am interesting front end, I also not bad 🌟 ~