How do I get a value from a JObject?

There are 'n' bombs placed on a circle. Each bomb has a value 'v' and range 'r'. If we detonate bomb at postion i, we will get value vi but we won't get the value of other bombs in the range [i-ri...i+ri]. What is the maximum value we can achieve?

  • Answer:

    You can solve this using an [math]O(n^3)[/math] solution using memoization to remember the solution of the subproblem (i, j). Solution(1, n) = Best Of 'soln' (for (i = 0 to n)   soln = Solution(0, i-(go beyond range of bomb i)) + V_i + Solution(i+(go beyond range of bomb i), n)

Dhruv Matani at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.