Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ec46abc

Browse files
Merge pull request youngyangyang04#2187 from fwqaaq/patch-46
Update 0674.最长连续递增序列.md about rust
2 parents 78f1d9f + 3cf32c8 commit ec46abc

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

‎problems/0674.最长连续递增序列.md‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,9 @@ func findLengthOfLCIS(nums []int) int {
302302
}
303303
```
304304

305-
### Rust:
306305

306+
### Rust:
307+
>动态规划
307308
```rust
308309
pub fn find_length_of_lcis(nums: Vec<i32>) -> i32 {
309310
if nums.is_empty() {
@@ -321,6 +322,27 @@ pub fn find_length_of_lcis(nums: Vec<i32>) -> i32 {
321322
}
322323
```
323324

325+
326+
> 贪心
327+
328+
```rust
329+
impl Solution {
330+
pub fn find_length_of_lcis(nums: Vec<i32>) -> i32 {
331+
let (mut res, mut count) = (1, 1);
332+
for i in 1..nums.len() {
333+
if nums[i] > nums[i - 1] {
334+
count += 1;
335+
res = res.max(count);
336+
continue;
337+
}
338+
count = 1;
339+
}
340+
res
341+
}
342+
}
343+
```
344+
345+
324346
### Javascript:
325347

326348
> 动态规划:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /