CARVANS (wrong answer)

whats my error?

 t = int(input())
    for i in range(t):
        n=int(input())
        ls = list(map(int, input().split()))
        arr=[]
        for i in range(n):
            arr.append(ls[i])

        count = 1
        for i in range(len(arr)-1):
            if arr[i]>arr[i+1] or arr[i] == arr[i+1]:
                count+=1
        print(count)

There is an error in the logic of the second loop which is counting the car at maximum speed.

Try this test case in your code
1
5
10 50 30 20 100

The solution of the above test case is only one car will have maximum speed but your code is giving 3 cars will have maximum speed.

1 Like