邓心一 пре 6 година
родитељ
комит
490850ba77
1 измењених фајлова са 19 додато и 0 уклоњено
  1. 19 0
      easy/674.longest-continuous-increasing-subsequence.go

+ 19 - 0
easy/674.longest-continuous-increasing-subsequence.go

@@ -0,0 +1,19 @@
+func findLengthOfLCIS(nums []int) int {
+	n := len(nums)
+	if n < 2 {
+		return n
+	}
+	max, cnt, pre := 1, 1, nums[0]
+	for i := 1; i < n; i++ {
+		if pre < nums[i] {
+			cnt++
+			if max < cnt {
+				max = cnt
+			}
+		} else {
+			cnt = 1
+		}
+		pre = nums[i]
+	}
+	return max
+}