I'm sick of being bad at algorithm questions. Is it possible to become good (not just improve)?

I don't think you're in the same position as the other guy

I didn't get stuck on the literal first question ("check if a string has all unique characters"). But I do get stuck on those level of problems

Most people who claim they suck at algorithm questions honestly just haven't done enough of them and understood them deeply

So how do I understand them deeply? My problem is, like that guy, I see an algorithm problem and go "uhhhhhhhhhhhh". For example, my facebook interview had a problem to find the shallowest node binary tree, and I said use dfs keeping track of the level you're on. Then he said that wouldn't work if the sides are unbalanced (cause you would recurse on one side for a while but the shallowest node might be the first level). I didn't think of bfs until he told me "checking level by level would fix the problem". So the issue wasn't that I didn't know how dfs works, it's that I didn't realize that you should traverse the binary tree level by level breadth-wise to find the shallowest node.

Another example is my google interview. They asked me to make a domino class and methods to compare dominos and boxes of dominos (where [x, y] is the same as [y, x]). My first thought was "either check the values manually or make a lookup table of one of the dominos and iterate through the other domino to check if the value is there". The interviewer had to tell me there was a problem when you're comparing [x, x] [x, y] because hashing then incorrectly says the dominos are the same since x is in both.

/r/cscareerquestions Thread Parent