Friday, March 30, 2018

Being interviewee: Island count

March 30, 2018


It is my mock interview algorithm at 12:00 PM. I spent 17 minutes to write the algorithm. I learned a few lessons through the mock interview.

Mock interview performance

I was lazy and do not declare two variables visitRow and visitCol, and then I mix startRow with visiitRow, startCol with visitCol. I wrote the code and forgot to push four neighbors into queue, I pushed startRow, startCol to the queue instead.

I fixed the issue when I did white board testing. I finished the coding in less than 17 minutes, and I failed 3 test cases. It took me one minute to find the bug from line 47 to line 50. I fixed it in less than one minute.

Next time it is important to declare new variables for visitRow, visitCol, otherwise I may mix things together. Build a good habit.

Here is my C# code.

Here is my last practice five days ago.

I enjoy to write code using BFS and also using queue. It is fun and it is easy to make mistakes. But with more practice, I will be more comfortable to think using BFS.

No comments:

Post a Comment