Sachin always wanted to score more and more runs for his team. Sometimes he succeeds in doing that and sometimes he fails. He also has a habit of noting down the runs he scored after every match in his diary. After N  matches he always looks for his scores. In i-th match, he scores A[i] runs. Now he wanted to know the length of the maximum non-decreasing sub-segment in sequence A. As he wants to go for another match, help him in doing this task.
Example 1:
Input:                  
N = 6                       
A[] = {2, 2, 1, 3, 4, 1}
Output:
3
Explanation:
The maximum non-decreasing sub-segment is
the segment with numbers from the third to
the fifth one.
Example 2:
Input:
N = 3
A[] = {2, 2, 9}
Output:
3
Explanation:
The maximum non-decreasing sub-segment
is the numbers from the first to the third one.
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function compute() which takes the array A[] and its size N as inputs and returns the length of the maximum non-decreasing sub-segment.
 
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤10^{5}
1 ≤ A[i] ≤ 10^{9}

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Starter code: #User function Template for python3

class Solution:
    def compute(self, a, n):
        # write your code here


Solutions:
class Solution:

	def compute(self, a, n):
		max_length = 1
		current_length = 1
		for i in range(1, n):
			if a[i] >= a[i - 1]:
				current_length += 1
			else:
				max_length = max(max_length, current_length)
				current_length = 1
		max_length = max(max_length, current_length)
		return max_length


class Solution:

	def compute(self, a, n):
		c = 0
		b = [0]
		for i in range(n - 1):
			if a[i] <= a[i + 1]:
				c += 1
				b.append(c)
			if a[i] > a[i + 1]:
				c = 0
		return max(b) + 1


class Solution:

	def compute(self, a, n):
		mx_ = 1
		current = 1
		for index in range(n - 1):
			if a[index] <= a[index + 1]:
				current += 1
			else:
				mx_ = mx_ if mx_ > current else current
				current = 1
		mx_ = mx_ if mx_ > current else current
		return mx_


class Solution:

	def compute(self, a, n):
		if a == sorted(a):
			return n
		k = 0
		count = 1
		for i in range(1, n):
			count += 1
			if a[i] < a[i - 1]:
				count = 1
			if k < count:
				k = count
		return k


from sys import maxsize

class Solution:

	def compute(self, a, n):
		mx = -maxsize - 1
		i = 0
		j = 1
		while j < n:
			if a[j] < a[j - 1]:
				t = j - i
				i = j
				if t > mx:
					mx = t
			j += 1
		if j - i > mx:
			mx = j - i
		return mx


class Solution:

	def compute(self, a, n):
		i = 1
		j = 0
		max1 = 0
		while i < n:
			if a[i] >= a[i - 1]:
				j += 1
			else:
				max1 = max(max1, j)
				j = 0
			i += 1
		max1 = max(max1, j)
		return max1 + 1


class Solution:

	def compute(self, arr, n):
		maxi = 1
		length = 1
		for i in range(n - 1):
			if arr[i] <= arr[i + 1]:
				length += 1
			else:
				length = 1
			maxi = max(maxi, length)
		return maxi


class Solution:

	def compute(self, a, n):
		lenght = 1
		maxi = 1
		for i in range(n - 1):
			if a[i] <= a[i + 1]:
				lenght += 1
				maxi = max(maxi, lenght)
			else:
				lenght = 1
		return maxi


class Solution:

	def compute(self, a, n):
		max_count = 1
		count = 1
		for i in range(n - 1):
			if a[i] <= a[i + 1]:
				count += 1
				max_count = max(count, max_count)
			else:
				count = 1
		return max_count


class Solution:

	def compute(self, a, n):
		c = 0
		ma = 0
		i = 0
		if len(a) <= 2:
			return 1
		while i < n - 1:
			while a[i] <= a[i + 1]:
				c += 1
				i += 1
				if i > n - 2:
					break
			if c >= ma:
				ma = max(ma, c + 1)
				c = 0
			if i > n - 2:
				break
			if a[i] > a[i + 1]:
				i += 1
				c = 0
		return ma


class Solution:

	def compute(self, a, n):
		x = [0]
		count = 0
		for i in range(n - 1):
			if a[i] <= a[i + 1]:
				count += 1
				x.append(count)
			if a[i] > a[i + 1]:
				count = 0
		return max(x) + 1


class Solution:

	def compute(self, a, n):
		ct = 0
		m = 0
		for x in range(n - 1):
			if a[x] <= a[x + 1]:
				ct += 1
			else:
				ct += 1
				m = max(ct, m)
				ct = 0
		return max(m, ct + 1)


class Solution:

	def compute(self, a, n):
		c = 1
		d = 0
		for i in range(n - 1):
			if a[i + 1] >= a[i]:
				c += 1
			else:
				if c > d:
					d = c
				c = 1
		if c > d:
			d = c
		return d


class Solution:

	def compute(self, a, n):
		c = 1
		ans = 0
		for i in range(n - 1):
			if a[i] <= a[i + 1]:
				c += 1
			else:
				ans = max(ans, c)
				c = 1
		ans = max(ans, c)
		return ans

def main():
	T = int(input())
	while T > 0:
		n = int(input())
		a = [int(x) for x in input().strip().split()]
		ob = Solution()
		print(ob.compute(a, n))
		T -= 1
if __name__ == '__main__':
	main()


class Solution:

	def compute(self, a, n):
		l = [0] * n
		l[0] = 1
		for i in range(1, n):
			if a[i] >= a[i - 1]:
				l[i] = l[i - 1] + 1
			else:
				l[i] = 1
		return max(l)


class Solution:

	def compute(self, a, n):
		l = []
		cnt = 0
		for i in range(n - 1):
			if a[i + 1] >= a[i]:
				cnt += 1
			else:
				l.append(cnt + 1)
				cnt = 0
		if len(l) == 0:
			return cnt + 1
		elif max(l) > cnt:
			return max(l)
		else:
			return cnt + 1


class Solution:

	def compute(self, arr, n):
		res = -1
		count = 1
		for i in range(n - 1):
			if arr[i] <= arr[i + 1]:
				count += 1
				res = max(res, count)
			else:
				res = max(res, count)
				count = 1
		if res == -1:
			return n
		return res


class Solution:

	def compute(self, a, n):
		i = 0
		j = 1
		temp = 1
		count = 1
		while j < n:
			if a[i] <= a[j]:
				j += 1
				i += 1
				temp += 1
			else:
				temp = 1
				i = i + 1
				j += 1
			if count < temp:
				count = temp
		return count


class Solution:

	def compute(self, a, n):
		ac = 1
		b = []
		for i in range(n - 1):
			if a[i] <= a[i + 1]:
				ac += 1
			else:
				b.append(ac)
				ac = 1
		b.append(ac)
		b.sort()
		if len(b) == 0:
			return 0
		else:
			return b[-1]