Count Strictly Increasing Subarrays | PHP program to count number of strictly increasing subarrays ; Initialize count of subarrays as 0 ; Pick starting point ; Pick ending point ; If subarray arr [ i . . j ] is not strictly increasing , then subarrays after it , i . e . , arr [ i . . j + 1 ] , arr [ i . . j + 2 ] , ... . cannot be strictly increasing ; Driver program
< ? php function countIncreasing ( $ arr , $ n ) { $ cnt = 0 ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) { for ( $ j = $ i + 1 ; $ j < $ n ; $ j ++ ) { if ( $ arr [ $ j ] > $ arr [ $ j - 1 ] ) $ cnt ++ ; else break ; } } return $ cnt ; } $ arr = array ( 1 , 2 , 2 , 4 ) ; $ n = count ( $ arr ) ; echo " Count ▁ of ▁ strictly ▁ increasing ▁ " , " subarrays ▁ is ▁ " , countIncreasing ( $ arr , $ n ) ; ? >