The interviewer asked a simple question designed to screen the clinically incompetent, and this guy used it as an opportunity to show the extent of his skills and knowledge, which is the whole point of an interview.
The interviewer asked a simple question designed to screen the clinically incompetent, and this guy used it as an opportunity to show the extent of his skills and knowledge, which is the whole point of an interview.
That, as well as the ball of code that was the boilerplate, made me assume that this was some kind of parody of actual interviews. It wasn't until I was reading through the tortoise-and-hare bit that I realized the author was actually being serious.
Honestly, I'm kind of surprised that that kind of question even comes up in interviews--I think like easily 99% of a startup's tech problems are probably better reflected by "How do we handle rounded corners in legacy browsers" or "How do you provision a server because we can't afford AWS" or "What would you consider three essential libraries for Javascript on the backend, and why?".
These CS questions just seem like underhanded trivia, especially when you dress up straightforward problem with a bunch of extra noise. They'd be fun to work through with an interviewee, as a way of seeing how they think about a problem, but just dropping it on them as sink-or-swim in a hostile environment doesn't seem very nice.
That, plus the setup of the code with all the variables right there, meaning that you'd of course be tempted to break encapsulation and solve the problem by just adding a "visited" flag to each board[x][y] cell. That's the smarter engineering thing to do, because you a) have access to that state as the problem is setup and b) know that visiting any cell will only ever land you in the same successive cell.
Again, the question is bad because it takes a reasonable question ("Can you detect this loop?") and then foists on the interviewee boilerplate that literally begs to not follow the problem constraints.
Have you actually interviewed developers? I have interviewed around 50-60. There's absolutely no way even 2% would answer that question correctly, unless we're talking Google/Apple/Facebook candidates.
I myself would probably fail to remember Floyd's algorithm, it's been too many years since my comp sci competition days (I used to do ACM, Topcoder, others). But I can certainly find it and implement it if I ever face a problem like that.
If you had recently graduated, it may not seem that way, but wait 20 years, and all the algos that you don't use regularly will be forgotten.
If you're going to ask tricky algo questions, you must allow people to use the internet.
"Ok, let's try your code. I'll read out a list of moves and you'll show me how it works"
and the fact that the code doesn't work would have become obvious.
Where is the flaw?
In other words, you're not free to iterate the moves of the game as many times as you please; the moves come in a single sequence. Adjust your code to keep track of those moves, and the solution becomes (almost) equivalent to the simple one.
You’ll notice, for example, that Christine asking him to try out his code while she reads out the moves doesn’t match the template she provided, either.
JM2C.
20 years from now, the idea of hiring programmers with interviews will be as weird as the idea of hiring an orchestra cellist with an interview.