Sunday, April 29, 2018

Being interviewer: Leetcode 152 Maximum product subarray

April 29, 2018

Introduction


It was my 10:00 pm mock interview. We both finished our algorithms in first 30 minutes. Then we spent extra one hour 20 minutes to work on algorithms together. I asked two algorithms for the peer to solve.

Here is the first algorithm called Leetcode 152: Maximum product subarray

Mock interview


The peer worked on the solution, and then we had discussion and then our discussion lasted more than 30 minutes.

Here is the transcript.

The peer wrote a brute force solution in less than 2 minutes, code is from line 54 to line 64. Two days ago, I helped a young undergraduate student to work on the brute force solution more than 10 minutes. What is big difference. I was so amazed and could not stop expressing my biggest surprise.

And then we had discussion about optimal solution using time complexity O(n). I tried to explain to the peer that his algorithm is not so good since it could not apply to the double array. And then he said that if it is a double array then it is another problem.

One more argument we had is about the algorithm he proposed from line 88 to line 112. The problem is that I could not understand his algorithm, I was too lazy to think and I need to run a simple example first.

I decided to give out the hint, I wrote the hint from line 32 to line 45. I like to introduce the dynamic programming algorithm, and help the peer to follow the idea.

And then the peer continued to work on his idea, he wrote down the notes from line 66 to line 86. The peer is very good at writing pseudo code and explain thing.

He did told me that he worked on ICPC contest in high school, and he found out that mock interview algorithms are easy etc. We talked about codeforce contest etc.


No comments:

Post a Comment