Introduction
It was a 10:00 AM mock interview. I met a peer who is super talented programmer and also very good mentor to write clean code and also readable code. He helped me to think about design along the 30 minutes mock interview.
Code review
Here is transcript for C# code and with analysis. I did spend first 10 minutes to write nicely an analysis for the algorithm.
Small accident
The code I wrote cannot pass the test case to find the interval, and then I could not find the logic problem. The peer told me on line 7 and line 8, I should check GetLength(0) < 1 instead. He said that he did not know C# very well, but he thinks that the checking is not necessary.
Advice from the peer
The peer learned how to programming through open source C++ projects, he read a lot of code. I was surprised to learn that he wrote beautiful code using queue and stack.
He advised me on line 22, design the return of function getIntervalOverlap, do not need to use third number in return array. Since if the interval is not found, then by checking startValue and endValue the interval can be defined.
He also advised me in the function getIntervalOverlap, do not need to return empty array using new int[]{maxStart, maxStart}, let the code fall through the checking on line 28 to line 39.
One additional note
Since the peer worked on the algorithm first, I worked on my algorithm next. So I did ask a lot of good questions through his algorithm. The peer was motivated and shared his opinion to write readable code and clean code.
I asked three additional algorithms after the mock interview, the peer solved all of them. I gave the comment like that in the sentence: "If I am a google interviewer, I will hire you on the spot.".
The peer is in Germany, graduating very soon from K.I.T. He learned programming from open source project, most of them are Mozilla open source C++ project. He read a lot of code.
My last practice
My last practice is on January 8, 2019. The blog is here.
No comments:
Post a Comment