Showing posts with label Array of array products. Show all posts
Showing posts with label Array of array products. Show all posts

Thursday, March 29, 2018

Being interviewee: Array of array products

March 29, 2018

Introduction


It is my algorithm to write in the mock interview. I remembered that I have to work on one multiplication from left to right iteration using dynamic programming, and then two multiplications from right to left calculation.

I have to learn again to write a correct solution in less than 10 minutes. This time I spent 18 minutes, and also I got a hint from the peer. The peer told me to define a variable leftToRight to save product of array elements on line 18, and also switch the order of line 22 and 24 to assign the value first, and then do the multiplication next.

Code review


Here is my C# practice.


Saturday, December 16, 2017

Dynamic programming should be daily practice

Dec. 16, 2017

Introduction


It is hard to get used to write bug-free code for dynamic programming. Specially base case handling.

Here is C# code I practiced on Dec. 16, 2017 10:00 AM. The code I wrote had a bug to handle the array with length 1, the product should be 0 instead of 1.

Feelings


This practice I felt much better. First I read the problem statement loud, and then I spent over 5 minutes to go over the test case, and explained the brute force solution and its time complexity. And then go to optimal one, how to apply the two linear scan integrated with left neighbor or right neighbor products with one more multiplication.

First try to explain very clearly the idea, and then it is very easy to write the code just following the idea.

I have practiced this algorithm more than 4 times since March, 2017. I still made an error on edge case. I just added tags for all past practice using Leetcode 238: product of array except itself, so I can easy go over the past practices and review them.


Get organized


It is most important task to get organized, review every practice in one setting. So I can figure out how I develop good understanding of the problem through each mistake, and also get some ideas what to work on next.

Source code is the key information to document how good/ not good I am in terms of algorithm analysis, coding style, and also whiteboard testing.


March 21, 2016, here is the blog about the practice.

Oct. 29, 2017, here is the blog about the practice.

Dec. 16, 2017 practice is Here.