1
1
# 674. Longest Continuous Increasing Subsequence
2
- LeetCode problem: [ 674. Longest Continuous Increasing Subsequence] ( https://leetcode.com/problems/longest-increasing-subsequence/ )
2
+ LeetCode problem: [ 674. Longest Continuous Increasing Subsequence] ( https://leetcode.com/problems/longest-continuous- increasing-subsequence/ )
3
3
4
4
## LeetCode problem description
5
5
Given an integer array ` nums ` , return the length of the ** longest strictly increasing subsequence** .
@@ -26,7 +26,7 @@ Output: 1
26
26
[Constraints]
27
27
28
28
1 <= nums.length <= 2500
29
- -104 <= nums[i] <= 10000
29
+ -10000 <= nums[i] <= 10000
30
30
----------------------------------------------------------------------------------------------
31
31
```
32
32
@@ -54,7 +54,27 @@ public class Solution {
54
54
}
55
55
}
56
56
57
- return dp .Max (); // If you want to beat 90%, change this line by using a local variable to record the max value in iteration.
57
+ return dp .Max (); // If you want to beat 90%, refer to Java code.
58
+ }
59
+ }
60
+ ```
61
+
62
+ ## Java
63
+ ``` java
64
+ class Solution {
65
+ public int findLengthOfLCIS (int [] nums ) {
66
+ var result = 1 ;
67
+ var dp = new int [nums. length];
68
+ Arrays . fill(dp, 1 );
69
+
70
+ for (var i = 1 ; i < nums. length; i++ ) {
71
+ if (nums[i] > nums[i - 1 ]) {
72
+ dp[i] = dp[i - 1 ] + 1 ;
73
+ result = Math . max(result, dp[i]);
74
+ }
75
+ }
76
+
77
+ return result;
58
78
}
59
79
}
60
80
```
@@ -80,24 +100,6 @@ class Solution:
80
100
// Welcome to create a PR to complete the code of this language, thanks!
81
101
```
82
102
83
- ## Java
84
- ``` java
85
- class Solution {
86
- public int findLengthOfLCIS (int [] nums ) {
87
- var dp = new int [nums. length];
88
- Arrays . fill(dp, 1 );
89
-
90
- for (var i = 1 ; i < nums. length; i++ ) {
91
- if (nums[i] > nums[i - 1 ]) {
92
- dp[i] = dp[i - 1 ] + 1 ;
93
- }
94
- }
95
-
96
- return IntStream . of(dp). max(). getAsInt(); // If you want to beat 90%, refer to C#'s code comment.
97
- }
98
- }
99
- ```
100
-
101
103
## JavaScript
102
104
``` javascript
103
105
var findLengthOfLCIS = function (nums ) {
@@ -111,7 +113,7 @@ var findLengthOfLCIS = function (nums) {
111
113
}
112
114
})
113
115
114
- return Math .max (... dp) // If you want to beat 90%, refer to C#'s code comment .
116
+ return Math .max (... dp) // If you want to beat 90%, refer to Java code.
115
117
};
116
118
```
117
119
0 commit comments