Why getting wrong answer even code is correct???
Neighbouring Enemy problem
Suppose that dp[i] stores the frequency if each element in the array.
Then the answer upto index i should be: dp[i]=max(dp[i-1],dp[i-2]+dp[i]*i)
Why getting wrong answer even code is correct???
Suppose that dp[i] stores the frequency if each element in the array.
Then the answer upto index i should be: dp[i]=max(dp[i-1],dp[i-2]+dp[i]*i)