Consider points on a line on the x-axis starting from 0 towards a positive direction.
There are N people standing on some points and there are M points that are dirty
I need to find out the minimum time required to clean all the dirty points.
At each second each person can move on point in any direction left or right or can stay
When a person comes to a dirty point the point gets cleaned
Example:
Consider person on [5,10] and dirty = [8] mean person is at point 5 and 10 and point 8
is the dirty point. The second person can go to point 8 and clean it. This will require 2 seconds
Consider [100,300] and dirty = [200,400] the first person could go from point 100 to point
200 and at the same time the second person could go from point 300 to 400
This will take 100 seconds.
Not sure how to approach it. Could one follow the greedy approach and simply move towards
the point that is closest. But then what if there are two points that are closest