I like that question. Feels like it showcases enough knowledge to quickly filter out people who know what they're doing. And also show you their thought process.
My first thought was about looping backwards and adding to the next column the way you would if you did the math on paper.
But then I was like. Why wouldn't we just make the computer do it in constant time with one line.
let n = [1,2,3];
function inc(nArr, addend) {
return parseInt(nArr.join("")) + addend;
}
inc(n, 1) // output 124
// or maybe add another line to the function if you wanted it as an array still
inc(n, 1).toString().split("").map((d) => parseInt(d)); // output [1, 2, 4]
Curious if that's about how it usually went (when they didn't take 45 minutes lol)
Like what if a printer just worked when you needed it to. Like you needed to print and you print and it prints.
Lucky I'm not a big hardware guy. HP and Epson would be so screwed by all these super smart ideas I got in my head.
@cisgenderhaver People being like. If I can't live in her, then you can't either. Bro. You wouldn't fucking live in there.
Oh, except if you didn't have a home.
@shadowzelda99 Lol. They literally built the games and controllers to work that way. Have you ever tried to pick up an item 2 steps away from you in smash bros?
Google is getting rid of the traditional search that they've spent decades optimizing and replacing it with this.
Also. The word your thinking of is poop actually.
I mean. I don't think companies are actually using the leetcode website for the interviews.
I would say that "implement an lru cache" or "write a review for counting words" are in the same vain as leetcode style questions. They prioritize memorizing very very specific and targeted things.
In fact. If you look up "LRU cache" the very first result is leetcode.