Basically, I was given a whiteboard test to do a certain task during the interview, and I did everything right, covering edge cases, talking about worst and best case run times, etc and the interviewer said everything was completely wrong and wouldn't give me a reason why it was wrong. I asked him for feedback and he said that I completely missed the boat and that I probably wasn't a good technical fit for the job. I don't understand this. When I arrived home, I retyped the code I had written for the whiteboard test on my computer and compiled it and everything worked exactly how he wanted it to in the whiteboard test. What's the deal here?
Either you were wrong, or they were wrong. In both cases, the non-recruitment is a good thing.
- He didn't get your answer : they are too self-confident. Better avoid that kind of firms.
- He did get your answer, but decided to play with you to see your reaction : this company is not a pleasant place to work in, you will be treated bad.
- He did get the answer, but didn't like your style. In which case he could have asked you to use his own guidelines, to see if you can conform.
Unless you were wrong(I cannot check), they are too arrogant to be nice to work with, whatever the reason(unless someone sees another possible reason). Too arrogant to accept a solution that is not theirs.
EDIT : his change of mind at the end is really suspicious. He probably saw something in you he didn't like. And he's not going to tell you.
Sometimes the hiring manager doesn't understand the answer or solution given to them, even if it is technically correct.
You've asked for feedback (good) and reflected on your performance from the technical side (good), but have you reflected on how you presented?
- Did you notice the hiring manager looking confused?
- Did you change your approach based on these cues (if there were any)?
- Did you build rapport whilst you were presenting? Did you ask if there were any questions as you went along?
Heads up: I am talking about the EU, the situation might be different in the US.
He probably wanted to test your interpersonal skills. He needs to see how you react if challenged rudely. Asking for more specific feedback is the right response in this situation.
Asking him "What specifically makes you think this code is inadequate? Maybe we can look together how to fix it" would be best. It's all about being a good team-player, open to criticism etc. So you need to stay calm and constructive.
I know multiple interviewers in IT who do this to every candidate. (If they had a few beers, they will tell you this is one of the best ways to detect aspergers.) IT is a field where the common impression is that interpersonal skills are lacking, but more and more necessary. So recruiters do a quick test.
The career services from my University even warned us that this test is waiting for us and told us how to react. Once you know what the test is about, the challenge changes. You are no longer at a risk of reacting defensively, but it becomes a challenge to keep a straight face through this piece of theater. (I'm not a fan of this test personally, but if you are warned, it is easy to pass.)
PS Another field where this happens a lot is international business. People in this field typically have good interpersonal skills, but they are also very much needed in cross-cultural settings. Every graduate trainee-ship position in a multi-national company that I know of (from doing interviews myself or through the other students in my batch) had a very similar test.
PPS You can not exclude that the interviewer just needed any excuse to refuse you or still that he was acting totally irrationally. Yet, even in those situations it would be best to answer in the same way as if it was the aforementioned test.