Earlier quoted context omitted.
In this case, it played out as a wrote it - I offered some solutions to the problem and thought about different ways to solve it, then implemented the one I thought was best on the whiteboard. About halfway through he asked me why I wasn't implementing the best version, so I thought some more about it and couldn't come up with an in-place solution (which is very hard to find in an interview setting), so I continued d…
You had a hint that there was an in place solution and a set of pointers. I mean the only real question here is how many spots you need to look ahead... I understand that whiteboard can be frustrating and hard, but it sounds like your interview was the exact kind of interview people try to make
In the past when I've been the hiring manager, I've had inexperienced interviewers ask my candidates questions like this for all kinds of positions - when you look at who does well in other interviews and gets an offer (and performs well), it basically never correlated at all to performance in whiteboard-only CS-focused interviews.
In this case I was interviewing for a full-stack senior position where there would almost certainly be zero systems-level coding, so the interview should have been a throwaway at best.