Consecutive steps to roof top | Function to count consecutive steps ; count the number of consecutive increasing height building ; Driver code
function find_consecutive_steps ( arr , len ) { let count = 0 ; let maximum = 0 ; for ( let index = 1 ; index < len ; index ++ ) { if ( arr [ index ] > arr [ index - 1 ] ) count ++ ; else { maximum = Math . max ( maximum , count ) ; count = 0 ; } } return Math . max ( maximum , count ) ; } let arr = [ 1 , 2 , 3 , 4 ] ; let len = arr . length ; document . write ( find_consecutive_steps ( arr , len ) ) ;