Introduction
I wrote a dynamic programming at 10:00 PM mock interview. I made a few mistakes after white board testing, and then I depended on the web compiler and fixed the issues.
Here is the code.
Performance issues
First one is on line 7, <= 1, not < 1; second one is related to calculate the product, line 19 and line 26. The product should include current element's value; the third one is line 25, it should keep the first dynamic programming result and then continue to add more multiplication.
No comments:
Post a Comment