Finding the shortest prefix such that all the elements in the prefix are less than or equal to the elements in the rest of the array .
$ partitions = 0 ; for ( $ current_max = $ arr [ 0 ] , $ i = 0 ; $ i < $ n ; $ i ++ ) { $ current_max = max ( $ current_max , $ arr [ $ i ] ) ;