Number of elements that can be seen from right side | Python3 program to find number of elements that can be seen from right side ; Driver code
def numberOfElements ( height , n ) : NEW_LINE INDENT max_so_far = 0 NEW_LINE coun = 0 NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT if height [ i ] > max_so_far : NEW_LINE INDENT max_so_far = height [ i ] NEW_LINE coun = coun + 1 NEW_LINE DEDENT DEDENT return coun NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 6 NEW_LINE height = [ 4 , 8 , 2 , 0 , 0 , 5 ] NEW_LINE print ( numberOfElements ( height , n ) ) NEW_LINE DEDENT