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 1cd5bb4 commit 4372832Copy full SHA for 4372832
leetcode/daily/3105/sol.go
@@ -0,0 +1,35 @@
1
+package main
2
+
3
+import "fmt"
4
5
+func longestMonotonicSubarray(nums []int) int {
6
+ res := 1
7
+ tmp := 1
8
9
+ for i, v := range nums[1:] {
10
+ if nums[i] < v {
11
+ tmp++
12
+ res = max(res, tmp)
13
+ } else {
14
+ tmp = 1
15
+ }
16
17
18
19
20
+ if nums[i] > v {
21
22
23
24
25
26
27
28
+ return res
29
+}
30
31
+func main() {
32
+ nums := []int{1,4,3,3,2}
33
34
+ fmt.Println(longestMonotonicSubarray(nums))
35
0 commit comments