Hacker News new | ask | show | jobs
by ricardoreis 2770 days ago
Here are some of the popular array-based coding interview questions for your practice:

How do you find the missing number in a given integer array of 1 to 100? (solution) [1]

How do you land a job at "startups like Uber and Netflix; big organizations like Amazon, Microsoft, and Google; and service-based companies like Infosys or Luxsoft"?

Easy - by rote memorization. And a healthy sense that it's to best not question the basic idiocy behind cargo-cult interview tactics like these.

Because apparently genuinely useful critical thinking skills -- beyond such trivial matters such as how to get a better space-time tradeoff on that petabyte-scale fibanocci generator[2] our customer desperately needs you to design a viable POC for right now, on the whiteboard, before lunch -- basically aren't needed at these companies.

Notes:

[1] You think I'm just being snarky? It's famously common out in hedgefund-land for people to get hired more or less on the basis of being able to whip out a deadpan response to "gee-whiz" questions like these. And to get "flushed" for their inability to do the same. Startups aren't quite so naively reliant on shibboleth questions of this sort -- but but only slightly so.

[2] I'm being slightly hyperbolic with this example -- but only slightly. I've long since lost count of the number of times been asked "design" questions really only slightly more ridiculous than this example. And as a matter of fact I've been asked an "advanced fibanocci" question -- and apparently received a job offer to a large extent on the basis of my ability to "nail" it -- quite recently

1 comments

Would you be looking for the solution where you subtract every number in the array from 5050? If anyone says that they 99% studied it.

A more "natural" sulution would be to sort the list first, and then look for consecutive array items where the difference is not 1.

I just woke up (still in bed). I've not seen this question before. For about 2 seconds I thought of iterating through and creating a map and... Wait a second, if one number is missing, I can just find the sum and subtract! Admittedly, I would have had much more trouble in a high pressure situation.

I think questions like this are fun and novel and also have absolutely no place in an interview for software developers.

Edit: the slightest of arguments for a question like this is can they find novel runtime optimizations. A work sample test is better. Grab some crap code from the codebase like a double forloop that should have been a map look up and have them make it more performant.

Would you be looking for the solution where you subtract every number in the array from 5050?

Unless they can swear up and down that what they actually do at this company, for at least a significant part of the day, is throw each other against the wall (er umm, whiteboard) and insist that they solve problems like these (and do so elegantly) within 10 minutes or less...

... or get fired ...

... then what I'll be looking for is simply -- the door.

Would you be looking for the solution where you subtract every number in the array from 5050? If anyone says that they 99% studied it.

I was asked this exact question at my on-campus interview with one of the Big Five software companies for a Program Manager internshi between my 3rd and 4th years of college.

I had done no “leetcode grinding”-style prep.

Subtract from 5050? No, I didn’t think of that. But I did think of summing the numbers 1..100 with a for loop, sum the numbers in the input array, and subtract.

Not the perfect solution. But it’s O(n).

And I did get the internship.

My point being not that I’m some kind of algorithmic prodigy: I’m very much not. But if a college kid can solve it without any prep, nor rote memorization as GP suggests...

If you're asked to sort a list and if you suggest something better than bubble sort, it means you 100% studied it. There is no way someone could come up with the quicksort(or alike) algorithm on an interview.
Insertion sort is actually the one that comes naturally for me. :)