new:新增Cangjie题解:最长连续递增序列

This commit is contained in:
Chemxy
2024-09-13 20:40:37 +08:00
parent 513440ad8f
commit 8127baf3fe

View File

@ -491,7 +491,24 @@ int findLengthOfLCIS(int* nums, int numsSize) {
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
}
```