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 ) Console . Write ( " Not ▁ Possible ▁ to ▁ " + " cover ▁ all ▁ intervals STRNEWLINE " ) ; else Console . Write ( res + " STRNEWLINE " ) ; } }