getting wrong answer for test cases plus help to resolve
Getting wrong answer
Can you please explain approach you used?
so , basically I have created a frequency array to maintain the frequency of all elements and my dp[I] says max score obtained by using first I numbers .
instead of using dp[i] to check the first i numbers, use it to check, what would be the result if number i was selected.
Code for reference:
even I meant the same as selecting the first I numbers by including and excluding the ith number
ok I got it instead of making the dp array of size of freq map we need to make the size of array of size of maximum element. I assumed that the consecutive numbers would be present
Please mark the doubt as resolved if everything is clear.