rb9's blog

By rb9, 4 years ago, In English,

I recently started learning dynamic programming, while solving some classical problems I encountered 2D range sum, and this which were solved using dp with inclusion and exclusion. Can anyone explain how can I tackle this types of problems? Any help will be appreciated.

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

4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

To solve this problem, i search all posible squares and add to the solution. All this can be doing in O(n^3*logn) (if you search all intervals and then doing a binary search). You can see my code. By inclusion and exclusion, I dont know how to do it.