Find maximum of minimum for every window size in a given array | PHP program to find maximum of minimum of all windows of different sizes Method to find maximum of minimum of all windows of different sizes ; Consider all windows of different sizes starting from size 1 ; Initialize max of min for current window size k ; Traverse through all windows of current size k ; Find minimum of current window ; Update maxOfMin if required ; Print max of min for current window size ; Driver Code
< ? php function printMaxOfMin ( $ arr , $ n ) { for ( $ k = 1 ; $ k <= $ n ; $ k ++ ) { $ maxOfMin = PHP_INT_MIN ; for ( $ i = 0 ; $ i <= $ n - $ k ; $ i ++ ) { $ min = $ arr [ $ i ] ; for ( $ j = 1 ; $ j < $ k ; $ j ++ ) { if ( $ arr [ $ i + $ j ] < $ min ) $ min = $ arr [ $ i + $ j ] ; } if ( $ min > $ maxOfMin ) $ maxOfMin = $ min ; } echo $ maxOfMin , " " ; } } $ arr = array ( 10 , 20 , 30 , 50 , 10 , 70 , 30 ) ; $ n = sizeof ( $ arr ) ; printMaxOfMin ( $ arr , $ n ) ; ? >