Great solution, got to know how different intutions get to same solution I thought in this way which might seem easier to understand: Consider a single element from array. There are 3 possibilities for it: 1) The element is present in your current array (considered subsequence) and you take it. 2) The element is present in your current array (considered subsequence) and you dont take it. 2) The element is not present in your current array (considered subsequence) If you see 2 and 3, they are same. So dontpick contributes twice. Hence, dp[i][k] = pick + 2*dontpick
@joshthwu8 ай бұрын
Great explanation! I spent about an hour and a half after the contest but still couldn't understand why we had to multiply by 2 when we chose not to take the number. However, I suddenly understood it during your explanation. Thanks a lot!
@xyz9568 ай бұрын
bro just , you related with the knapsack problem, and built on that, that was super awesome bro , thanks.
@for_the_creators2898 ай бұрын
my god i just did this que and burh posted it u r very great >>>>>>> fr the best no words , good luckkkkkkk
@PrinceTiwari-md7of8 ай бұрын
very nice explanation😃
@avijitdey9928 ай бұрын
thanks a lot brother
@nishantkumarjha46448 ай бұрын
thanks bro..really helped
@IK-xk7ex8 ай бұрын
Subsequence keeps the order, subset - no order required
@shashankvashishtha44548 ай бұрын
subsequence and subset are same, but the difference is that subset contain unique elements.
@adityajhunjhunwala97398 ай бұрын
in subsequence order of elements matter whereas in subsets order of elements doesnt matter