Sunday, March 25, 2018

Being interviewer: Sudoku solver

March 25, 2018

Introduction


It is such great experience to work with a software engineer from Israel 10:00 am mock interview.  The peer also told me that she works for one of top four software company in the world. She worked on Sudoku solver.

As an interviewer, I like to write down some highlights for my code review.

Code review


Here is the solution I reviewed. First of all, the peer wrote down the analysis very clearly and asked me if I followed her idea after she wrote some of the code from line 21 to 44. After she wrote the solution to call recursive for next iteration, she asked me the feedback.

Highlights of my code review:

1. line 25 to line 26, I added those two lines. I explained that there is a bug to find next position of '.' char. Line 23, I changed column = j to column = 0, and add line 25 and line 26 to start from (i, j).

2. line 56, I explained to the peer that no need to check, HashSet.Remove can handle the case if the char is not in hashset.

3. line 88 to 91, I explained to the peer why backtracking is necessary. Her argument is that next iteration the element will be replaced by the available number. And then I gave her the example, first row with first two elements 5 and 3, and 3 empty space with '.', if we work on the third '.' and try the last available number but fails, we need to put '.' back and then continue to work on second '.'. Recover the original status.

Using graph like the following:
5 3 _  _   _
              _ fail ->'.', work on third dot, (0, 4)
          next iteration to work on second '.'

4. work on nextRow and nextCol calculation. Originally the peer wrote (emptyRow + 1)% n, (emptyColumn + 1) %m,


Actionable Items


It is very good to work with the peer on this algorithm. Today is Sunday. I choose to stay at home and work on mock interview. Yesterday I spent over 90 minutes to work with a peer on budget cap calculation. Later I talked to my roommate Emma, she told me that I have to think for other people. If I meet  a strong player on algorithm and data structure, I will talk over 90 minutes. Think about the other way, same applies to the peer I met as well.

Emma is a very good IELTS teacher, and she told me to work on cleaning the living room table together. What I did is to learn and stay organized. We both laughed about the shopping I did in Seattle, and I did make a mistake to purchase too many Nike shoes for myself. I bought 3 pairs of Nike shoes, one pair I wore two days, it broke my skin near my ankle. I went to Seattle with my friend from Shanghai, she laughed about me how I can wear 3 pairs of sneakers. It turned out not cheap for 3 pairs of shoes, $150 Canadian dollars.

No comments:

Post a Comment