Thursday, December 14, 2017

Base case

Dec. 13, 2017

It is a long mock interview for me, I worked together with the peer second time, the first time was less than a week ago, the blog is here.

We worked from 10:00 PM to 12:40 AM. I asked two more questions to interview the peer.

The peer helped me to write an algorithm related to recursion, memoization, edit distance problem.

Code review

The C# code is here.


Follow up

After the mock interview, I realized that the memoization has issue. I should declare the memo jagged array with size new int[length1 + 1][length2 + 1] instead of int[length1][length2].

The memoization should record the value for the top row and top column.

Line 42 and line 47.

One thing I can do is to test the code using Leetcode online about memoization design issue. Another one is to read dynamic programming solution, and check the two dimension matrix and its size, base case handling.

The peer brought up a lot of good discussion about the code, I changed the structure of the code to remove redundant code from line 62 to line 73.

No comments:

Post a Comment