Introduction
It is the second time I asked leetcode 54: spiral matrix in the anonymous interview as an interviewer. I met a peer who was willing to be interviewed, and followed my hint and try to write a solution using one loop instead of four for loops for each direction.
Code review
Here is Java code to review. The peer spent around 20 minutes to work on coding, I was able to see how good the peer can write readable code.
I told the peer that he did better than me. When I was asked this algorithm and the idea to write one loop only, it took me more time to come out the ideas, and I needed two hints, one for direction array, one for visited array.
Compared to the peer, I knew that I have to learn to stay open and think hard in the mock interview.
No comments:
Post a Comment