mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-06 23:28:29 +08:00
new:新增Cangjie题解:最长连续递增序列
This commit is contained in:
@ -491,7 +491,24 @@ int findLengthOfLCIS(int* nums, int numsSize) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
### Cangjie
|
||||||
|
```cangjie
|
||||||
|
func findLengthOfLCIS(nums: Array<Int64>): Int64 {
|
||||||
|
let n = nums.size
|
||||||
|
if (n <= 1) {
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
let dp = Array(n, repeat: 1)
|
||||||
|
var res = 0
|
||||||
|
for (i in 1..n) {
|
||||||
|
if (nums[i] > nums[i - 1]) {
|
||||||
|
dp[i] = dp[i - 1] + 1
|
||||||
|
}
|
||||||
|
res = max(res, dp[i])
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user