Number of elements that can be seen from right side | PHP program to find number of elements that can be seen from right side . ; Driver code
< ? php function numberOfElements ( $ height , $ n ) { $ max_so_far = 0 ; $ coun = 0 ; for ( $ i = $ n - 1 ; $ i >= 0 ; $ i -- ) { if ( $ height [ $ i ] > $ max_so_far ) { $ max_so_far = $ height [ $ i ] ; $ coun ++ ; } } return $ coun ; } $ n = 6 ; $ height = array ( 4 , 8 , 2 , 0 , 0 , 5 ) ; echo numberOfElements ( $ height , $ n ) ;