There is a rod of length n lying on x-axis with its left


Question: There is a rod of length N lying on x-axis with its left end at x = 0 and right end at x = N. Now, there are M weak points on this rod denoted by positive integer values(all less than N) A1, A2, ..., AM. You have to cut rod at all these weak points. You can perform these cuts in any order. After a cut, rod gets divided into two smaller sub-rods. Cost of making a cut is the length of the sub-rod in which you are making a cut. Your aim is to minimise this cost. Return an array denoting the sequence in which you will make cuts. If two different sequences of cuts give same cost, return the lexicographically smallest.

Solution Preview :

Prepared by a verified Expert
Engineering Mathematics: There is a rod of length n lying on x-axis with its left
Reference No:- TGS02263613

Now Priced at $10 (50% Discount)

Recommended (91%)

Rated (4.3/5)