Question: You are given an array of m lamp posts with non - negative integer light values, where 0 means that the lamp post can only
You are given an array of m lamp posts with nonnegative integer light values, where means that the lamp post can only light up a section outside one house, means it can light a given house plus the two immediately neighboring houses on either side of this house, and a light value of k means it can light a given house plus the next k houses on either side of this house k consecutive houses in total You can place a lamp post next to any house. A house may be lit by several lamp posts.
aIf we have an array of five lamp posts what is the minimum number of lamp posts needed to light the street with len houses?
bProve the greedy algorithm that sorts the set of lamp posts in decreasing order and picks lamp posts until all houses on the street are lit is optimal.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
