Live data from Hacker News

How to Rock an Algorithms Interview

blog.palantir.com

1–10 of 169 posts

Re: How to Rock an Algorithms Interview

#2
This is a great, meaty blog post. I really like the first point about always coming up with a brute force solution so that you at least have something, and so that you have a chance to think about the problem a little. I've seen candidates skip the brute force approach too many times so that they can immediately work on a more optimal solution. At the end, they often end up without any solution at all. I guess Knuth's advice about premature optimization applies too interviews as well.

There's also a good Quora page that talks about the (complementary) coding side of algorithm questions: http://www.quora.com/What-is-needed-to-write-flawless-code-d...

Re: How to Rock an Algorithms Interview

#3
Real good advice. Totally agree with the brute force thing, I usually resort to that first just to put something down. Related note, Palantir was at the MIT Career Fair recently and when talking to prospective candidates, they asked them a little brain teaser as a filter on the spot.

Re: How to Rock an Algorithms Interview

#4
>Given a whiteboard and one hour, determine whether the person across from you is someone you’d like to work with, in the trenches, for the next n years.

If we ignore the requirements of one hour...

Brute force: Hire a random candidate that hasn't been hired by you before. Fire them when you get fed up with them. Hire a different candidate. Repeat.

Greedy Algorithm: Develop the model for an ideal candidate, assign that candidate a numerical model and then compute the distance from the current candidate to the ideal candidate.* Hire the candidate with the lowest computed distance. If a candidate comes along with a lower computed distance fire the old candidate and hire the new one.

Simulated Annealing: As with the greedy algorithm, but instead of hiring based solely on lowest computed distance, include a small % chance that you will randomly fire the candidate and hire candidate that is slightly worse. (Optional extension to the algorithm is to keep the best candidate so far cached somewhere, potentially a transporter buffer).

Genetic Algorithms: From your pool of candidates, select the top candidates. Breed these candidates, randomly introducing mutations. Repeat again with the progeny of the previous pool, until one of the candidates passes a satisficing threshold 'distance' score.

* = Notice that this is the actually the most difficult part of (almost any useful application of) these algorithms but I managed to hand-wave right through it.

Re: How to Rock an Algorithms Interview

#5
post #4

>Given a whiteboard and one hour, determine whether the person across from you is someone you’d like to work with, in the trenches, for the next n years. If we ignore the requirements of one hour... Brute force: Hire a random candidate that hasn't been hired by you before. Fire them when you get fed up with them. Hire a different candidate. Repeat. Greedy Algorithm: Develop the model for an ideal candidate, assign th…

Divide and conquer: Assign all applicants randomly to teams. Run competitive coding competition. Reject all but the winning team. Split the winning team into smaller ones, and repeat.

Re: How to Rock an Algorithms Interview

#6
Disclaimer: I work at Palantir Technologies. These are my own opinions and not my company's.

The Palantir post is great for how to handle yourself when you are already there. Steve Yegge's "Get That Job at Google" is a great how-to-really-prepare piece. http://steve-yegge.blogspot.com/2008/03/get-that-job-at-goog...

A couple other suggestions:

* Find sample questions that similar companies use. Work through them. Discover what you don't know. Find if you're weak on dynamic programming, graph algorithms, algorithm analysis, etc. Then get strong on those. The less you want to do sample problems, the more important they are for you.

* When practicing interview questions, whiteboard at least some. Talk through them. Really go through a question in every detail.

* Before you interview at your dream company, interview elsewhere with similar difficulty questions. In my opinion, it should be another company that you'd like to work at but don't covet. If that doesn't work for you, a technical or even a non-technical friend could play the role of interviewer (you'll have to give the non technical friend questions!). Nerves have been a giant issue for me in interviews - and this has significantly helped.

* Calm down as much as you can and forgive yourself when you make errors. The questions at good companies are calibrated to have non-obvious solutions, interviewers expect you to struggle a bit. Candidates who freeze-up and attach their mind to one (usually wrong track) solution fail interviews. I've done it. If you've practiced with the first three bullet points, this should be less likely.

Re: How to Rock an Algorithms Interview

#8
post #4

>Given a whiteboard and one hour, determine whether the person across from you is someone you’d like to work with, in the trenches, for the next n years. If we ignore the requirements of one hour... Brute force: Hire a random candidate that hasn't been hired by you before. Fire them when you get fed up with them. Hire a different candidate. Repeat. Greedy Algorithm: Develop the model for an ideal candidate, assign th…

Epic, really. That's one for the 'best of HN'.

I'd hate to work for you though ;)

Re: How to Rock an Algorithms Interview

#9
post #4

>Given a whiteboard and one hour, determine whether the person across from you is someone you’d like to work with, in the trenches, for the next n years. If we ignore the requirements of one hour... Brute force: Hire a random candidate that hasn't been hired by you before. Fire them when you get fed up with them. Hire a different candidate. Repeat. Greedy Algorithm: Develop the model for an ideal candidate, assign th…

Two more approaches:

1) There's the well-known Secretary (or Marriage, or Sultan's Dowry) Problem (http://en.wikipedia.org/wiki/Secretary_problem). It has three caveats, though:

* Solution assumes that you have a lot of (e.g. ~20) candidates.

* It is assumed that you can sum up each candidate's ability in a single number. This is the hardest part, since the human mind works relationally and assigning absolute numbers to anything is hard.

* The probability of picking the best candidate is only 1/e.

But at least there's a guaranteed bound on the probability of success, that some of the other methods lack.

2) (If possible) Hire the engineer and HR person at the same time and have the HR candidates evaluate the engineering candidates. Then run Knuth's stable marriage algorithm (http://en.wikipedia.org/wiki/Stable_marriage_problem) to pick the best candidates for each.

Re: How to Rock an Algorithms Interview

#10
>Given a whiteboard and one hour,

We, hiring folks, aren't limited to just that anymore. There's github, linkedin, hn/reddit posts, random google stalking, etc.

I can find a lot about you, your attitudes, opinions, ability to communicate, style, etc. that, or you for whatever reason (paranoid, on the lam, aren't passionate) have zero online presence).

The face to face interview is mostly to confirm or refute what I've already learned about you.

Post reply on HN