Startup|Phone Screen|
238
Jun 05, 2020

Imagine you are bridge repair contractor.
Bridge is made up of several segments say upto 100 segments.
Each segment is numbered starting from 1 to 'n'.
To fix the bridge, patch sheets are used. Patch sheet can be several segments in legth.
For simplicity, if we think of segment lenth to be 1meter, then sheet could be several meters in length.

Bridge inspection reports list of bad segments for a bridge. Eg. [ 1, 2, 5, 8 ]
Inventory has also put a constraint that you 'have to' use 'm' sheets for the job. (m <= sizeof(bad segments))
Manufacturing has put in constraint that we can produce sheets of only one size.
Your job is to device an algorithm that finds optimum length of the sheet that covers all the bad sections.

Comments (1)