File tree 3 files changed +73
-0
lines changed
solution/0600-0699/0674.Longest Continuous Increasing Subsequence
3 files changed +73
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,32 @@ public:
131
131
};
132
132
```
133
133
134
+ ### **Rust**
135
+
136
+ ```rust
137
+ impl Solution {
138
+ #[allow(dead_code)]
139
+ pub fn find_length_of_lcis(nums: Vec<i32>) -> i32 {
140
+ let n = nums.len();
141
+ // Here dp[i] represents the longest lcis that ends with `nums[i]`, should be 1 by default
142
+ let mut dp: Vec<i32> = vec![1; n];
143
+ let mut ret = dp[0];
144
+
145
+ // Let's dp
146
+ for i in 1..n {
147
+ dp[i] = if nums[i] > nums[i - 1] {
148
+ dp[i - 1] + 1
149
+ } else {
150
+ 1
151
+ };
152
+ ret = std::cmp::max(ret, dp[i]);
153
+ }
154
+
155
+ ret
156
+ }
157
+ }
158
+ ```
159
+
134
160
### ** Go**
135
161
136
162
``` go
Original file line number Diff line number Diff line change @@ -115,6 +115,32 @@ public:
115
115
};
116
116
```
117
117
118
+ ### **Rust**
119
+
120
+ ```rust
121
+ impl Solution {
122
+ #[allow(dead_code)]
123
+ pub fn find_length_of_lcis(nums: Vec<i32>) -> i32 {
124
+ let n = nums.len();
125
+ // Here dp[i] represents the longest lcis that ends with `nums[i]`, should be 1 by default
126
+ let mut dp: Vec<i32> = vec![1; n];
127
+ let mut ret = dp[0];
128
+
129
+ // Let's dp
130
+ for i in 1..n {
131
+ dp[i] = if nums[i] > nums[i - 1] {
132
+ dp[i - 1] + 1
133
+ } else {
134
+ 1
135
+ };
136
+ ret = std::cmp::max(ret, dp[i]);
137
+ }
138
+
139
+ ret
140
+ }
141
+ }
142
+ ```
143
+
118
144
### ** Go**
119
145
120
146
``` go
Original file line number Diff line number Diff line change
1
+ impl Solution {
2
+ #[ allow( dead_code) ]
3
+ pub fn find_length_of_lcis ( nums : Vec < i32 > ) -> i32 {
4
+ let n = nums. len ( ) ;
5
+ // Here dp[i] represents the longest lcis that ends with `nums[i]`, should be 1 by default
6
+ let mut dp: Vec < i32 > = vec ! [ 1 ; n] ;
7
+ let mut ret = dp[ 0 ] ;
8
+
9
+ // Let's dp
10
+ for i in 1 ..n {
11
+ dp[ i] = if nums[ i] > nums[ i - 1 ] {
12
+ dp[ i - 1 ] + 1
13
+ } else {
14
+ 1
15
+ } ;
16
+ ret = std:: cmp:: max ( ret, dp[ i] ) ;
17
+ }
18
+
19
+ ret
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments