I’m doing this problem-
I’m thinking about sorting all the horses and then doing range DP, with a range containing the minimum number of operations given that the only horses in the stable are the horses in the range. To process a range, I’ll go through all central elements and set them as the root of the tree, with the subtrees being the left and right side of the range.
However, I don’t really know how to merge the two previous numbers into a single one. Could anyone give me some insight on how to do this?
Bump.