All Tracks Data Structures Advanced Data Structures Segment Trees Problem

Inverse Subarray
Tag(s):

Easy-Medium, Segment Trees, Two-pointer, approved

Problem
Editorial
Analytics

You are given an array consisting of N integers. Now, you need to find the length of largest sub array of this array where first element of this sub array is \( \ge \) than the last element of that sub array.

Let us consider a sub array from index i to j. You need to find the length of the maximum length sub array, such that \(A[i] \ge A[j]\).

Sample Input:

The first line contains a single integer T denoting the number of test cases in a single test file. Each test case is spread over 2 lines, in the following format :

The first line of each test case contains a single integer N denoting the size of the given array A. The next line contains N space separated integers, where the \(i^{th}\) integer denotes \(A[i]\).

Sample Output:
For each test case output answer in new line.

Constraints:

\( 1 \le T \le 10 \)

\( 1 \le N \le 10^5 \)

\( -10^9 \le A[i] \le 10^9 \)

SAMPLE INPUT
1
5
5 4 3 2 1
SAMPLE OUTPUT
5
Explanation

The max length sub array which can be chosen is from index 1 to 5.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

Alacriti Infosystems

Challenge Name

Alacriti Fresher Hiring Challenge

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?