-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest02.java
More file actions
28 lines (27 loc) · 752 Bytes
/
Test02.java
File metadata and controls
28 lines (27 loc) · 752 Bytes
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
package Test_2022_10;
public class Test02 {
public static void main(String[] args) {
int[] arr = {1,2};
Test02 test02 = new Test02();
System.out.println(test02.findLengthOfLCIS(arr));
}
public int findLengthOfLCIS(int[] nums) {
if (nums.length == 1) {
return 1;
}
int slow = 0;
int maxLength = 1;
int length = 1;
for (int i = 1; i < nums.length; i++) {
if (nums[i] > nums[i - 1]) {
length++;
if (length > maxLength) {
maxLength = length;
}
} else {
length = 1;
}
}
return maxLength;
}
}