3 ms·
> When is the last time you had to write your own array sorting function or function that performs search in an array? About a month ago I wrote a merge sort r
by simonster 14y ago
> When is the last time you had to write your own array sorting function or function that performs search in an array?
About a month ago I wrote a merge sort routine in JavaScript where the comparison function is a person. There is no library function for this, because the response is asynchronous.
> There is always a function for that in a high-level languages like Ruby (index), JavaScript (indexOf) or Python (index).
These functions don't do what your interviewers asked. Python's index won't give you duplicates, and it's at least equally non-trivial to use JavaScript's indexOf with two arguments in a loop as it is to use a hash, and the algorithmic complexity of the former is much worse, so why would you do it?
> Another sad thing, which I gladly didn’t see that much (but there still were a few interviewers) in the Bay Area compared to the East Coast, is asking terms, function names, definitions, slang, etc. Expecting people to remember functions’ syntax is a sin in itself!
On this point, I agree.
- azat_co 14y ago1) array.sort didn't work for you? if not than this is an exception and could be an example of a good interview question ie solving a real problem 2) that is right, but in the algorithm of the answer you could use index function which makes code more compact