Driver code
public static void main ( String [ ] args ) { int x = 3 ; Interval [ ] intervals = { new Interval ( 0 , 7 ) , new Interval ( 2 , 14 ) , new Interval ( 4 , 6 ) } ; int N = intervals . length ; int res = minDistanceToCoverIntervals ( intervals , N , x ) ; if ( res == - 1 ) System . out . print ( " Not ▁ Possible ▁ to ▁ " + "cover all intervalsNEW_LINE"); else System . out . print ( res + "NEW_LINE"); } }