Asked in Google
Anonymous User
2396

There is one question that is just asked As I remember only a few part of the question if someone can help

N=4
[4,10][7,13][20,30][1,40]--> 6,3,10,20
[4,10]->10-4= paint 6
[7-13]->13-10=paint 3
[20,30]->30-20 paint 10
[1,40]->20
If someone can provide a solution asap! I was thinking to merge the overlapping interval and keep in stack and everytime a new element is visited I will check the top of the stack and then make a conclusion. Again I am not sure the exact approach.

Comments (9)