625. Maximum width of line segment
0
Medium
A line segment in an 0-indexed integer array nums is a pair (i, j) for which i < j and nums[i] <= nums[j]. The width of such a segment is j - i.
Given an integer array nums, Print the maximum width of a segment in nums. If there is no line segment in nums, Print 0.
Input Format
First line takes an integer N(size of array)
Second line containing N integers describing array a1,a2,a3,a4,...an.
Second line containing N integers describing array a1,a2,a3,a4,...an.
Output Format
Print the maximum width of a line segment in nums.
Example
Input
6
6 0 8 2 1 5
Output
4
Constraints
2 <= N <= 5 * 10^4
0 <= nums[i] <= 5 * 10^4
0 <= nums[i] <= 5 * 10^4
Loading...
View Submissions
Console