Also it would be helpful if someone could help me figure out what is wrong with the following code for the above question as the code is not able to compute the answer when N=500 : [C++] Ajay Rajnikanh - Wealth Disparity
I think I have done the exact same thing i.e check the last book of a shelf and the first book of the other shelf and swap then K times and sort them each time you swap them
I feel that the second hint is a bit misleading as you say"map dp"and I went searching through the net to find out who you meant but then I realised what I had to do was not complicated at all.
Thanks for your help.
The thing is i haven't learned these algorithms before, I just use whatever logic I think that will give me the answer, is that bad or is it okay to solve these problems without knowing its proper approach?