Hacker News new | ask | show | jobs
by globular-toast 1606 days ago
You're not the only one, but it's the equivalent of walking round a foreign country with a phrasebook versus being fluent in the native language. In this case, for example, you seem unaware that reduce is just doing a funny thing with a loop and won't be faster, but you've been seduced by shorter looking code because it looks more clever. There is, in fact, value in the reduce method but it's nothing to do with speed or efficiency (it's because it's declarative). But if this were Python, and the reduce was a call to numpy, then it would be about speed and efficiency. The point of doing stuff like leetcode is (or should be) to test real understanding of the technology, not an ability to copy/paste from StackOverflow.
1 comments

But if you can grind these what's the point then? All I'm doing at work is building glorified crud apps. I'm sure it's what many, many software engineers are doing. Not all, but many. My understanding of e.g. Django is much more important to my daily work than being able to come up with the fastest way to find a maximum value in an array.
Nobody said anything about the fastest way to find a maximum value in an array. The comment you were replying to was just about finding a maximum value in an array. Idiomatic usage would presumably be a bonus but anything not ridiculously inefficient would be fine. This is absolutely something that someone building a CRUD app should know how to do without StackOverflow.