adaptatron's blog

By adaptatron, 6 weeks ago, In English

Problem Link

Target Audience : If you are not able to come up with the $$$O(n^2)$$$ algorithm in 5 minutes, and the $$$O(n)$$$ algorithm in additional 5 minutes, this tutorial is for you. If you are a beginner to Dynamic Programming on Prefix, this 1D DP problem is a good starting point for you to learn the technique. This tutorial assumes that you already have some experience with 1D DP.

I came across a simple yet elegant problem, which might be trivial to some but a good learning experience for others. So I created a blog that talks about how to optimize DP transitions by switching from Pull DP to Push DP.

You can submit your $$$O(n^2)$$$ and $$$O(n)$$$ solution here :

If you have an alternate solution for any of these problems, do let me know in the comments.

If you have more practice problems on this concept, please share them in the comments below and I'll add them to the practice contest.

  • Vote: I like it
  • +1
  • Vote: I do not like it