Check if it is possible to rearrange rectangles in a non | 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 ; initialize the number of rectangles ; initialize n rectangles with length and breadth
function rotateRec ( n , L , B ) { var m = Number . MAX_VALUE for ( var 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 ; } var n = 3 ; var L = [ 5 , 5 , 6 ] ; var B = [ 6 , 7 , 8 ] ; if ( rotateRec ( n , L , B ) == 1 ) document . write ( " " ) ; else document . write ( " " ) ;