looking for a better solution to a dp problem

Revision en1, by OverKiller, 2020-11-07 10:52:04

This problem appeared in a Hiring Challenge on Hackerrank and i couldn't solve it in better than $$$O(N^2)$$$ which was giving TLE. Here is the problem below:

Spoiler

I can't think of a solution better than $$$O(N^2)$$$. Any help/hints will be appreciated.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English OverKiller 2020-11-07 10:52:04 615 Initial revision (published)