Check if it is possible to rearrange rectangles in a non | C # implementation of above approach ; Function to check if it possible to form rectangles with heights as non - ascending ; set maximum ; replace the maximum with previous maximum ; replace the minimum with previous minimum ; print NO if the above two conditions fail at least once ; Driver code ; initialize the number of rectangles ; initialize n rectangles with length and breadth
using System ; class GFG { static int rotateRec ( int n , int [ ] L , int [ ] B ) { int m = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( Math . Max ( L [ i ] , B [ i ] ) <= m ) m = Math . Max ( L [ i ] , B [ i ] ) ; else if ( Math . Min ( L [ i ] , B [ i ] ) <= m ) m = Math . Min ( L [ i ] , B [ i ] ) ; else { return 0 ; } } return 1 ; } public static void Main ( ) { int n = 3 ; int [ ] L = { 5 , 5 , 6 } ; int [ ] B = { 6 , 7 , 8 } ; if ( rotateRec ( n , L , B ) == 1 ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }