How should i solve this prpblem? I am not getting intution
Approach for solving?
Hey @pranjalarora98 Assume we perform the given operation over any array AA. Then, after performing any sequence of moves after which AA has only 22 elements, it can be proved that the original elements of the array get partitioned into 22 sub arrays. ( When we merge 22 elements, we consider they are in the same partition, and each sub array corresponds to an element among the 22 remaining elements in AA ).
So, we build a dynamic programming solution, where we cut the given array into 22 sub arrays in every possible way, and then solve individually for those 22 sub arrays ( recursively, considering them to be the originally given arrays), after which we can know the best possible way to divide the original array into 22 parts, that can be merged into a single element using the lowest cost.
You can see this video explanation too
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.