mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
Merge pull request #2187 from fwqaaq/patch-46
Update 0674.最长连续递增序列.md about rust
This commit is contained in:
@ -302,8 +302,9 @@ func findLengthOfLCIS(nums []int) int {
|
||||
}
|
||||
```
|
||||
|
||||
### Rust:
|
||||
|
||||
### Rust:
|
||||
>动态规划
|
||||
```rust
|
||||
pub fn find_length_of_lcis(nums: Vec<i32>) -> i32 {
|
||||
if nums.is_empty() {
|
||||
@ -321,6 +322,27 @@ pub fn find_length_of_lcis(nums: Vec<i32>) -> i32 {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
> 贪心
|
||||
|
||||
```rust
|
||||
impl Solution {
|
||||
pub fn find_length_of_lcis(nums: Vec<i32>) -> i32 {
|
||||
let (mut res, mut count) = (1, 1);
|
||||
for i in 1..nums.len() {
|
||||
if nums[i] > nums[i - 1] {
|
||||
count += 1;
|
||||
res = res.max(count);
|
||||
continue;
|
||||
}
|
||||
count = 1;
|
||||
}
|
||||
res
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Javascript:
|
||||
|
||||
> 动态规划:
|
||||
|
Reference in New Issue
Block a user