by quanto · 4y ago · 0 comments
That said, I have seen that even those firms without rigorous leetcode rounds have mini-leetcode questions during onsite that are the easiest of the easy leetcode problems; e.g. find the sum of an array of ints, find a duplicate item in an array, etc. So, I don't think you can avoid these questions completely, but at the same time, summing up an array seems like a fair sanity check for dev applicants. I saw one programmer (PhD!) from a Top-3 school in Europe that could not find a maximum value in an array. So, yes, some sanity checks, but I don't think this is what you are concerned about.
All those examples I mentioned above pay above (some well above) 150k USD TC.
var max = arr.reduce(function(a, b) { return Math.max(a, b); });
which is totally valid for javascript and also pretty neat. I would probably do some funny things with loops instead, wasting time and resources.
It was a CTO role and I'd just aced a presentation on "How to launch a new product" and I could not context switch to coding mode fast enough.
Even when I know how to do something, I look it up just in case. Sometimes there's a cleaner approach, or I learn that I don't fully understand the problem.
Let us assume that you are a competent worker that other firms want to hire. What is the best way to find people like you and to test/interview people with ADHD?
To be clear, I do not have ADHD, so I have no personal experience with this important topic.
Premature optimisation:
In most cases the performance would not matter. Instead of optimising for performance you should optimise for readability. IMHO IFs and FORs are way more readable in any context than any language specific methods like REDUCE and MAX.
Incorrect optimisation:
At least in modern browsers, simple IFs and FORs are the most optimised methods of doing anything. See for instance https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_... (Operations per second, higher is better).
The idea that “reduce” is language specific is frankly mind boggling. It’s no more language specific than a loop.
Mind you I’m talking in general and now in browser specifically
I take the exception that on this case in particular, the reduce is much more readable than a loop. Javascript isn't completely on the "anything non-imperative could as well be in machine code" league, but has plenty of problems that appear when you try to write other kinds of declarative code.