Sunday, August 26, 2012

Given a array of intervals, check if that have any gape efficiently


u will be given pairs.. u need to see whether they have any gaps..
u can think pairs are like intervals..
ex1: max no:20 pairs: 11-15, 0-5, 18-20, 14-19, 6-13 
 
the above has no gaps..because 0-5,6-13,11-15,18-20 have all numbers from 0 (min) to 20(max)
 
ex2: 11-15, 0-5, 18-20, 14-16, 6-13 this have gap as the intervals miss a number from 0 to 20 i.e.,17

No comments :