(Context: In chess, a queen can move along a row, column, or diagonal to attack. The N Queens problem is to place N queens on an NxN chessboard such that no two queens can attack each other.)
No one does poorly here because they are "bad at chess algorithms." They might do poorly because they think they're bad at chess algorithms. But this is not a "chess algorithm." It's an algorithm, with a chess skin.
But, sure, if you're bad at chess algorithms, I'll give you this problem: Given an N by N boolean matrix (all falses), set N cells to true such that no two rows, columns, or diagonals have two trues.
Same question, but with a boolean skin. Now will you be able to tackle it?
So, advice: Don't assume you're bad at __ type of algorithm question. For the most part, this isn't true. At most, there's a tiny bit of knowledge to tackle it (so you're not bad at it; you just don't know something). Nearly every time I hear someone say they're bad at some type of question, it's actually just an insecurity. They aren't even missing any knowledge.
The only partial exception here is recursion/dynamic programming, which does have its own little approach.
At a higher level: Can you ask for a new question if you're bad at that type?
You could, but it's risky. If I ask you a question that really involves pointers and you don't understand them, then okay. But realize that this might be a deal breaker for me. I might need that knowledge, or I might be concerned about the tendency to give up.
You're probably better off just voicing something like: "To be honest, I haven't worked much with pointers. I'm happy to give it a shot though, unless you want to move onto a different question."
Someone who's never come in contact with backtracking won't be able to solve n queens "in time", unless they pull a mathematics stunt, but those who do know backtracking won't struggle much.
On a higher level - how much of an "already seen the algorithm" crapshot are tech interviews?
And given the fact that a lot of the problems in your book are trivial in higher level languages (reversing a string is only hard if you somehow don't know how to do pointers) - what's your opinion on trying to use Java on a whiteboard in 2017? Has python officially become synonymous with pseudocode?
A properly conducted technical interview will not be about having seen the algorithm before. Some companies screw it up though. But then, these same companies also screw up other parts of the interview process.
I disagree that using certain languages makes a lot of problems trivial. Maybe it makes certain problem trivial, but those tend to be easier ones anyway. They're already trivial. And even if your language has a function that performs the exact thing being asked, the interviewer can easily ask you to go implement that thing.
Java is fine for a whiteboard. So is python. So are most languages.
No, python has not become synonymous with pseudocode. I'm not sure what you mean by that.
I'd say it is mostly that. Just do thirty to fifty leetcode medium problems (some of them on pen and paper), and you're good to go.
>will never be able to practice enough to do well on a well-conducted interview
Or in other words a true scotsman interview.
It sounds like you can't bring yourself to write "on an average interview at Google" because you wish they wouldn't pick common interview problems - but they do.
Based on what you just wrote, I'd certainly work through books of "interview questions". Because your phrasing just proved it works, even though ideologically that is not what candidates "should" do.
Taking a step back: If preparation can give a bad candidate a good shot at passing the interview, then that interview process is broken.
If you have a company with a bad implementation of whiteboard coding interviews (for example, who just pull questions out of Cracking the Coding Interview), then it's absolutely true that a bad candidate could pass this process.
This doesn't mean that whiteboard interviews are broken. It means that this company's implementation of whiteboard interviews is broken. There is a difference.
For Google specifically, their implementation is decent, but not ideal. A bad candidate would have low odds of passing an average interview at Google, but those odds are not as low as I'd like.
>> On a higher level - how much of an "already seen the algorithm" crapshot are tech interviews?
>I'd say it is mostly that. Just do thirty to fifty leetcode medium problems (some of them on pen and paper), and you're good to go.
Nobody in this thread cares if the reason this advice actually (in actual practice) often works is that the interview process is broken.
nobody cares if the reason we get the job is because we exploited a flaw, and we "shouldn't have" done it that way. Basically, where you just wrote,
>Taking a step back: If preparation can give a bad candidate a good shot at passing the interview, then that interview process is broken.
you should have written:
>Taking a step back: If preparation can give a bad candidate a good shot at passing the interview, then I have to admit, if you strictly want to increase your chances of getting a job, then you can do so by preparing -- but I grit my teeth while saying that, because that interview process is broken.
that would have been honest and matches the reason others had for the above thread! anyway, thanks for the responses.
I didn't get through at Google. However, I only asked for 3 weeks to prepare, and I have outside obligations (kids, coaching, that sort of thing). I can easily traverse a binary tree, print all permutations of a set, do DFS and BFS. But I'm not super sharp, especially at a whiteboard.
My review was "not bad, good analysis, but didn't make enough coding progress".
Maybe they were being nice. As I said in another comment, I'm not allowed to know what my scores or reviews were.
FTR, I was a math major, though I did take basic CS algorithms and data structures. So I have a background, but probably further to go than a typical CS major.
I know it will vary by individual, but how many hours, over what period of time, would you say counts as "enough practice" where you might start considering that you probably aren't going to be able to practice enough to do this. Could you ballpark it?
I'd prefer to avoid "unintelligent", but you know, a point at which you'd say, this probably isn't for you, might be time to get some new goals?
Back to leetcode I guess.
The more difficult ones feel like you absolutely have to have seen the problem before because there is complex relationship between the sub problems that are used to solve by induction/bottom up. How is someone supposed to solve these? Throwing out tons of guesses at the start feels like it'll still end up with me getting shown out before lunch time.
Recursion and memoization is easy but dynamic programming doesn't really feel as natural. Ways to get better? Just do more?
Once you have the recursive solution, the DP solution should be fairly easy. Draw out the recursion tree for an example (or do it more generally), convert it to a DAG by combining redundant nodes, and then do a topological sort. That topological sort is the order in which you need to solve the subproblems to get a DP solution.
If you want to flip a memoization problem into bottom-up dynamic programming: 1. Make sure you really understand the memoization approach 2. Look at the base cases. What are the very last things the recursive approach does? 3. Build up the next case from the base case. 4. Repeat
Generally, no. Not unless you want to look like a whiny stick-in-the-mud.