-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaxLength.java
62 lines (50 loc) · 1.36 KB
/
MaxLength.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.util.*;
import java.io.*;
/*
Name: Longest Increasing Subarray
Source: GeeksForGeeks
Link: https://practice.geeksforgeeks.org/problems/longest-increasing-subarray/0
*/
public class MaxLength {
public static void main(String args[]) throws IOException
{ //write your code here
Scanner scanner = new Scanner(System.in);
int test = scanner.nextInt();
int [] ans = new int[test];
int no = test-1;
while(no>=0)
{
int n = scanner.nextInt();
int [] arr = new int[n];
int count=0;
int temp=1;
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
String a[] = scanner.nextLine().split(" ");
for (int i = 0; i < n; i++)
{
arr[i] = Integer.parseInt(a[i]);
}
for (int i = 1; i < n; i++)
{
if(arr[i]>arr[i-1])
{
temp++;
if(count<temp)
{
count=temp;
}
}
else
{
temp=1;
}
}
ans[no]=count;
no--;
}
for (int i = test-1; i>-1; i--)
{
System.out.println(ans[i]);
}
}
}