6 posts
• Page **1** of **1**

How to solve this problem? Any hints or algorithm...

You may think about dynamic programming.

There will be two transitions:

1.) take and multiply the value at index p.

2.) do not take value at index p.

There will be two transitions:

1.) take and multiply the value at index p.

2.) do not take value at index p.

But value can be very large, how to use this value as a state of DP?

You have to find a formula.

Find a formula for fewer elements sets.You can use the formula larger elements sets

Find a formula for fewer elements sets.You can use the formula larger elements sets

**Posts:**1**Joined:**Tue Dec 05, 2017 1:56 am

You just need to memorize "position" state to determine whether to take value at that position or not.

As the length of array is 1000. You can easily manage that in dp.

As the length of array is 1000. You can easily manage that in dp.

Thanks everyone, including Rajib vai for helping me in this problem. AC...

6 posts
• Page **1** of **1**

Who is online

Users browsing this forum: No registered users and 1 guest