Tuesday, May 29, 2018

Being an interviewee : Insert intervals

May 29, 2018

Introduction


It is the interval algorithm but it is not easy for me to come out elegant idea to write simple code. I had some ideas, but before I came out the idea, I already wrote the code. The interviewer told me stop, and told me that I should make it simple.


Ideas 


Here is the transcript of the mock interview.

Hints pouring down 


I like the interviewer. He just quickly coached me through mock interview. I like to exaggerate how he did. He poured down hints one by one. I really like young talent Chinese graduate student, how hard he works, and he is willing to coach me. He did 3 times mock interviews with me, and this is the third time. I like his good collabration skills. I do believe that the future will be better with those young gradautes.

A few hints are given by the interviewer and the interviewer helped me to get the optimal solution and also very clean implementation:

1. About inserted interval, it can be replaced by current visited element
2. inserted interval can be replaced by the merge interval of two overlapped intervals.
3. Write simple code, I wrote the code to check next interval and logic is too complicated for the interviewer to follow. It may work, but the interviewer told me that it is better to discuss with the interviewer first.
4. The interviewer told me that it is better to ask hints, instead working on complicated solution. I do not totally agree on this.
5. If I am too busy to work on the code by myself, the interviewer may not have chance to work with me.

Follow up 


I wrote C# code and also I found a bug. Actually if I check my coding style and I should find the bug. Those two lines of code with variables insertedStart, insertedEnd, the scope should stay inside for loop. Now they are moved to line 60 and line 61.


No comments:

Post a Comment