We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c977df commit 3a120dfCopy full SHA for 3a120df
Dynamic Programming/300. 最长递增子序列.md
@@ -92,3 +92,26 @@ class Solution {
92
}
93
```
94
95
+
96
97
+Go 语言:
98
99
+```go
100
+func lengthOfLIS(nums []int) int {
101
+ dp := make([]int, len(nums))
102
+ dp[0] = 1
103
+ res := dp[0]
104
+ for i := 1; i < len(nums); i++ {
105
+ maxn := 0
106
+ for j := 0; j < i; j++ {
107
+ if nums[i] > nums[j] {
108
+ maxn = max(maxn, dp[j])
109
+ }
110
111
+ dp[i] = maxn + 1
112
+ res = max(res, dp[i])
113
114
+ return res
115
+}
116
+```
117
0 commit comments