mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-11 04:54:51 +08:00
new :新增Cangjie解题代码
This commit is contained in:
@ -337,6 +337,29 @@ pub fn length_of_lis(nums: Vec<i32>) -> i32 {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Cangjie:
|
||||||
|
|
||||||
|
```cangjie
|
||||||
|
func lengthOfLIS(nums: Array<Int64>): Int64 {
|
||||||
|
let n = nums.size
|
||||||
|
if (n <= 1) {
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
let dp = Array(n, item: 1)
|
||||||
|
var res = 0
|
||||||
|
for (i in 1..n) {
|
||||||
|
for (j in 0..i) {
|
||||||
|
if (nums[i] > nums[j]) {
|
||||||
|
dp[i] = max(dp[i], dp[j] + 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res = max(dp[i], res)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||||
|
Reference in New Issue
Block a user