Sunday, April 29, 2018

Being interviewer: Array quadruplet

April 29, 2018


I had a mock interview with a young undergraduate student with ICPC contest experience. So I like to ask him to solve my favorite algorithm Array quadruplet. I think that he did one on dynamic programming, and then I tried to evaluate how good he is.

Biggest surprise was that he gave me the solution I could not understand. And then I asked him a few question, ask him to explain using example. He did perfect job to explain the algorithm.

It turned out the algorithm is optimal solution. I like to post the answer for my own question asked more than 6 months ago. Here is my question link.

Mock interview

Here is the algorithm the peer wrote. At the end of interview, I asked him to connect to linkedin, it turned out that he worked for facebook as an intern already.

I could not believe that my mock interview practice was so many surprise and I just enjoyed the talk. Somehow I complained to the peer that I do not want to study so many system design interview, I do not want to try to memorize so many things, I like to work on the algorithm with the peer on mock interview instead.

We met and talked about one hour fifty minutes until the mock interview terminated the discussion. I could not believe that I enjoyed the discussion of the algorithm so much, I never expected that I will meet a super talent later in Saturday evening.

Time complexity

The algorithm provide by the peer is better on time complexity, since the two sum preprocessing is conducted on the iterating of the array in the same time, what ever in the hashmap should be with smaller indexes. We do not need to go through the list of the items in the key value since any one of them will work. 

It is similar to all other algorithm like merging 2 packages

Feedback from the peer

You just do as you do in the mock interview practice session, you should be able to do fine in any interview. That is my advice.

No comments:

Post a Comment