Thursday, May 31, 2018

Get lost in a depth first search, DP, tree algorithm again

May 31, 2018

Introduction


It is my favorite thing to do if I have luxury to spend a few hours. I like to learn the algorithm again called Maximum disjoint subtree product.

I read my own blog written after the contest in May, 2017. I read the code I wrote in the contest, and I like to make any point above zero. I wrote more than one hour and three hundreds of lines code, but I still scored zero. The hard working spirit really touchs my heart again.

I do have to get a coach and learn better way to think in terms of depth first search, dynamic programming and tree.



Algorithm study


Here is the code I spent time to play with. I need to get some help from my coach. I like to learn how he solves a hard level algorithm.

Getting smart after 12 months

May 30, 2018

What I like to do is to solve a subproblem first. Assuming that there is an array, we need to find two disjoint subarray with the maximum product. I like to define two dynamic programming solutions, and then I solve the problem first.

Here is C# solution I write. Time complexity is O(N), N is size of the array.


No comments:

Post a Comment