Driver Code
public static void main ( String [ ] args ) { ArrayList < ArrayList < Integer > > arr = new ArrayList < ArrayList < Integer > > ( ) ; arr . add ( new ArrayList < Integer > ( Arrays . asList ( 1 , 4 ) ) ) ; arr . add ( new ArrayList < Integer > ( Arrays . asList ( 2 , 2 ) ) ) ; arr . add ( new ArrayList < Integer > ( Arrays . asList ( 2 , 3 ) ) ) ; int n = arr . size ( ) ; if ( checkNonOverlapping ( arr , n ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }