/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int t= sc.nextInt();
while(t>0)
{
int n = sc.nextInt();
int speed[] = new int[n];
for(int i =0;i<n; i++)
{
speed[i] = sc.nextInt();
}
int count =1;
for(int i =0;i<n-1; i++)
{
if(speed[i]>= speed[i+1])
{
count++;
}
else{
count = count;
}
}
System.out.println(count);
t–;
}
// your code goes here
}
}
suppose the input is 10 12 11 2 5
here first car entering the race has speed 10 so the second car having 12 speed is not counted and till now second car is moving with speed of 10 after that car with speed 11 enters now 11 is again greater than the speed of 2nd car which is 10 so it will again move with speed 10 after that 4th car with max speed 2 enters now 2 is smaller than 10 so it will move with max speed that is 2 after that 5th car enters having max speed of 5 now the 4th car has speed of 2 so it will also continue with 2
Can any one check where am I doing wrong
t = int(input())
while(t):
n = int(input())
arr = list(map(int,input().split()))
tc = int(input())
while(tc):
chef=0
r = int(input())
for i in range®:
tem = i%n
if arr[tem]%2!=0 and arr[tem]!=1 and tem!=n-1:
chef+=arr[tem]-1
elif tem==n-1 and arr[tem]%2==0:
chef+=arr[tem]-1
elif tem==n-1 and arr[tem]%2!=0:
chef+=arr[tem]
elif tem<n-1 and arr[tem]==1:
a = arr[:tem][::-1]
for element in a:
if element%2==0:
chef-=element
else:
chef = chef+1
break
else:
chef+=arr[tem]
print(chef)
tc-=1
t-=1