Please explain the editorial in detail. How is the state considered in the editorial?.
Not able to understand the editorial
Please send me the link of the editorial
State in dp array: dp[i] represents the maximum sum possible till the ith element
We are taking an input n(number of elements in our array).
Then we are storing the elements in a map in line 40.
We are traversing the map in the lines 41-43 and storing unique elements in our vector.
Size of our vector is taken as n and we create the dp array of same size.
In the map, we have stored the frequencies of each unique character which is present in our vector.
Line 47: When we have only one element in our array. So dp[0]=b[0]*mp[b[0]] (mp[b[0]] is the frequency and b[0] is the element)
Rest of the code is for loop starting from i=1.
And the maximum possible value is stored in dp[n-1].
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.