'''
For a given array [a] of integers, 
count the number elements that are larger than the previous element

Example
a = [19, 20, 20, 21, 23, 20, 25, 26]
solution(a) = 5
'''  

def solution(a):
    inc_count = 0
    prev_el = int(a[0])
    for index in range(1, len(a)):
        cur_el = int(a[index])
        if cur_el > prev_el:
            inc_count += 1
        prev_el = cur_el
    return inc_count


print(
    solution([19, 20, 20, 21, 23, 20, 25, 26])
) #output: 5

print(
    solution([199,200,208,210,200,207,240,269,260,263])
) #output: 7

print(
    solution([20,19,18,17,17,15,13])
) #output: 0

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: