please help in solving this question using DP
Please help in solution
hi @goyalvivek
I don’t understand how u are trying to apply dp to this problem…
Either do it using brute force way (as u are already applying 2 loops), or by merge sort method…
I am unable to get the right value in dp array
approach- I am collecting all the no of pairs possible in dp array and in the end, the sum of all the elements in dp array = sum, but my code is not working properly, please check
@goyalvivek
i don’t understand what logic u are using to solve inversion count problem using dp…
there are 2 ways for it
- brute force
- merge sort implementation
https://www.techiedelight.com/inversion-count-array/
refer this for both the approaches…
U have to run ur inner loop from i+1 to n, not 0 to i… hence it gives wrong ans…
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.