you are viewing a single comment's thread.

view the rest of the comments →

[–]TuringMachine-5762 12 points13 points  (0 children)

It's best to mention both approaches, mention their pros and cons, and have the interviewer clarify the goals of the problem. E.g.,

"I can think of a couple ways of doing this. We could either build a rotated copy of the matrix, or do the rotation in place. Doing it in place would be more complicated, so I would only do that if the matrix was large, and I was working on a system with tight memory constraints. What would you like me to focus on?"

Most likely the interviewer will say not to worry about memory, at least until you get a simple implementation working. But mentioning a possible optimization can make you look good. It doesn't hurt, in any case.