Function to check if the intervals can be added by X to form non - overlapping intervals
function checkNonOverlapping ( arr , n ) { var dsu = [ ] ; for ( var i = 0 ; i < n + 1 ; i ++ ) { dsu . push ( i ) ; } for ( var i = 0 ; i < n ; i ++ ) { for ( var j = i + 1 ; j < n ; j ++ ) {