I had a really good tech interview a while back, where I had to reverse a string in place, and then reverse only the words in a string in place (so "this is a test" => "siht si a tset")
Anyway, I had a couple of off by errors. The interviewer asked me if I was sure I didn't have any, so I had a look through, stepped through the code, and lo and behold, I did. While I was doing this process, we ended up having a discussion about how unit testing would help avoid problems like off by 1 errors, and would make iterating through the code and refactoring a lot easier.
That's what a good tech interview should look like, not expecting someone to write perfect code, first time.
On a side note, I didn't end up getting the job, since they had apparently hired someone the day before I came in for the interview. Apparently I managed to apply for the job the day they closed applications, but they asked if I wanted to interview anyway, out of courtesy.
Anyway, I had a couple of off by errors. The interviewer asked me if I was sure I didn't have any, so I had a look through, stepped through the code, and lo and behold, I did. While I was doing this process, we ended up having a discussion about how unit testing would help avoid problems like off by 1 errors, and would make iterating through the code and refactoring a lot easier.
That's what a good tech interview should look like, not expecting someone to write perfect code, first time.
On a side note, I didn't end up getting the job, since they had apparently hired someone the day before I came in for the interview. Apparently I managed to apply for the job the day they closed applications, but they asked if I wanted to interview anyway, out of courtesy.