Thursday, December 14, 2017

Choose to be Maria or Matha

Dec. 14, 2017

Introduction


Bible story Mary Listens while Martha Labors (Luke 10:38-42) is my favorite, and I like to have wisdom to listen instead of worrying about so many things. And I want to write my mock interview experience and mainly reflect on my feedback. 

After both of us finished the turn to be interviewed, the peer told me that he tried to give me hint when I worked on the algorithm, but I did not give him chance to talk. It is not so good since I should pay attention to my peer. 

Also, I broke my promise to write optimal solution with time complexity O(logn) and space complexity O(1), but I just started to write at the very beginning to declare an array with space n, and copy the array to the new array using time complexity O(n)

Am I a good listener? I learned the story of Mary instead of Martha more than 15 years ago when I was in Florida, United States. I will read the bible story, and try to relate the story to my mock interview feedback. 


Mock interview


It is another normal mock interview, my peer did not show up so mock platform matched me with one 10:05 PM. It is the algorithm I worked on before, the last practice is documented in the blog in Sept. 2017.

C# code is here. The code passes all test cases but time complexity is O(n) not O(logn), the space complexity is O(n) not O(1). I will make quickly change to remove diff array and integrate the checking with difference value arr[i] - i where arr is the integer array and i is the index.

After I performed the algorithm, the peer said that he never met any one like me before. He liked me to present the analysis first, and the way I wrote the code to solve edge case, find lowest index with value arr[i] = i is very efficient. The peer gave me hint how to make the minor change from line 34 to line 46, I just said that let us work on simple example, [0,0,0,0,0] is the array with five zeros, how to find the first zero index, which is 0?

I analyzed the test case first, and then I said that I do not want to scan the array from middle index to left, I need to do binary search as well. I explained the idea but the peer said that he could not understand it. So I wrote the code line 39, and explained that I need to make sure that left neighbor is existing and its value is 0 as well, so I will do another binary search.

Follow up after mock interview


I like to write the code based on mock interview code, and then remove the code to declare extra array from line 14 to line 17.

My last three practices on the algorithm are here:

1. June 8, 2017    (.ca)
2. Sept. 4, 2017   (.sh)
3. Sept. 14, 2017 (.mp)

All the above 3 practices have issues, need to do code review.

June 8, 2017 practice is here. Sept. 4 practice is documented here. And Sept. 14 practice is here.

The C# code written in Dec. 14 is reviewed after the mock interview, and the code is here to fix the bug, time complexity and space complexity is lowered to optimal ones.


Lesson learned 


This mock interview I practice to read loud the problem statement, not in rush, complete the reading and also let the peer hear. Because I read the problem statement loud and slow, I found that the smallest index has to be found and it is a challenging task to achieve the goal. I just cannot miss it since I read loud and slowly, and use gentle voice to calm myself down.

The reading part is also very important to practice in the interview, do not try to read silently, speak each word clearly like an actor/ actress to read the script in Suits. I plan to write a blog about watching the video script reading.


Feedback from the peer


The peer has great education and also very good work experience in Seattle area. The peer mocks for fun.



No comments:

Post a Comment