by alta22433 · 12y ago · 0 comments
I honestly felt that this class was the most useful and relevant out of all CS classes I took as an undergraduate student.
Dynamic programming is very useful, and this problem is a classic. It's asked quite a bit in interviews.
This is actually a very important thing to look for in an interview. While it might not be "fair" in the sense that not all smart people can effectively answer it, it's absolutely effective to sort out who has a good grasp of algorithms (and memoization in particular). There are too many smart people out there to interview just for that; you've got to look for existing knowledge too.
So by asking this question, I suspect you are biasing towards people who have recently taken a survey of algorithms course. I'm having a hard time envisioning the hiring situation where I'd want that bias.
Also there are a couple of ways to approach this, I think it really helps elucidate how a person tackles a tricky problem upfront (does the person try to write the recurrence out first? does the person do the exponential recursive solution and then memoize? does the person visualize this like a graph, a table, or something else?)
"This feels like a dynamic programming/max-flow-min-cut/linear programming problem. I'd formalize it, look it up in a textbook, like Chvatal, or on Wikipedia, and find the precise problem class. Then I'd look for an appropriate code. Or, maybe go back to the problem origin and see if the actual problem maps in to one of the more general classes I just looked up."
Perhaps much more realistic an answer than some poking around on the whiteboard by someone who may have studied this in school anyway. Having a feeling for problems that should already be well-studied/solved can be more valuable than bumbling on to the solution after a few minutes.
There. Now, instead of asking for CS theory from candidates in the most hostile imaginable setting (that's what a job interview is: hostile) and telling yourself a cute little story about how you're determining how candidates handle interesting problems that require them to consult the literature: you actually allow the candidate to demonstrate how they would do that.
This is a question that is trivial to answer if you remember basic dynamic programming examples. It is nearly impossible to come up with the "right" answer without it. I'm trying very hard to understand what sort of hiring situation would be interested to know if someone understood basic dynamic programming (without knowing more advanced topics) or could suss it out on their own.