1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| // @Title: 最长连续递增序列 (Longest Continuous Increasing Subsequence)
// @Author: 15816537946@163.com
// @Date: 2021-01-24 19:48:35
// @Runtime: 8 ms
// @Memory: 4.2 MB
func findLengthOfLCIS(nums []int) int {
n := len(nums)
if n == 0 {
return 0
}
ans, ret := 1, 1
for i := 1; i < n; i++ {
if nums[i] > nums[i-1] {
ret++
} else {
ret = 1
}
ans = max(ans, ret)
}
return ans
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
|