Recently I had some interviews at a large company. I failed to get a job offer, but will likely re-apply in a year (their required period to wait). I may also apply at other companies in the mean time. One thing that I know I messed up on was the coding interviews.
There were two coding interviews. One right after the other. As best I could tell, the second one went great. I pretty much have to go on gut feeling because they don't give feedback on how you did on a particular interview. But, I solved both problems in that interview and with enough room to let me do some code optimizations so I don't see how I could have done much better.
The first coding interview was the one I totally bombed. It was a relatively simple problem, but I just couldn't think of the solution. Initially I wanted to get out a O(N^2) solution because that's what came to me first, but the interviewer just kept asking about whether I can make it faster. Eventually I was allowed to code out the solution I came up with first. But then, with way too much assistance on behalf of the interviewer, I got a solution that was more like O(N). And then we ran out of time.
I did quite a bit of practice coding on LeetCode before these interviews, but I'm still left feeling unprepared. The type of questions in these interviews are what I would describe as "not real world", or maybe "college" or "trivia" style. In this case specifically, it was the largest sum contiguous subarray problem. I've been writing software professionally for around 16 years, but that coding is totally different than the skills needed to solve these problems. I'm much more at home coding things like business logic, database access, or UI.
On LeetCode, what I've noticed is that there are some hard level questions that I do find hard, but then there are other hard questions that the solution flows right out and runs correctly without much more than fixing syntax errors. I'm talking like 10 or 15 minutes worth of effort. And on the other hand, I've had some easy or medium questions that take me all day.
When I interview again, I know I'm going to be dealing with the same kind of coding questions. I really feel like my ability to solve them is more of a coin flip rather than based on my skill. How should I be trying to prepare for this? Is it just a matter of more LeetCode type training?