Hacker News new | ask | show | jobs
by vanusa 1627 days ago
Finding the median with or without sorting first?

If it's the latter (essentially a test of whether they've memorized quickselect) then that sounds like a horrible filter, actually. Unless it's for the position of "Senior Quicksort Engineer".

1 comments

They are free to use the standard library, and use whatever language they like (eg python). It's not about how to sort
If some asks me to "calculate" something I assume they mean from scratch (without using a built-in). That's probably what a fair number of these people did.

Also, my sense is that Python is something of an outlier in having a mean and median functions in it standard library. I could be wrong, but AFAIK Go and JS do not, for example -- so people using those languages would surely bomb (at least on the median calculation part -- again, assuming they interpreted your question as "calculate from scratch").

I don't mean to be pedantic or split hairs. The point I'm trying to make is that even simple-seeming problems can have gotchas to them, depending on the context.

Interviewers could do better by either thinking just a bit more about the problems they select, or just communicating better. But many do not, unfortunately -- I have the sense they just pull problems out of the air, and see what sticks. Meanwhile counting the high number of fails as a success signal.

The site has a detailed spec and test input/output, you can build and run the tests

The standard library is to sort, not take the median

Well it does seem to be a cute filter for Python programming ability in that they definitely need to have taken a tour of the modern standard library to come up with

  min(x)
  max(x)
  statistics.mean(x)
  statistics.median(x)
But still - no 'for' loops? No if-then-else? You might be giving some of these candidates a pass.
It's really just to make the point that you will need to write real code and answer technical questions in this process. And it provides an easy way to for them to drop out if they decide they don't want to do that.
Well put. I appreciate your clarifications.