1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-14 01:49:41 +01:00
LeetCode/go/increasing-triplet-subsequence.go
Matej Focko 4bf8cc35ee
go: add «334. Increasing Triplet Sequence»
Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-08-12 20:39:49 +02:00

18 lines
234 B
Go

package main
import "math"
func increasingTriplet(nums []int) bool {
a, b := math.MaxInt, math.MaxInt
for _, x := range nums {
if x <= a {
a = x
} else if x <= b {
b = x
} else {
return true
}
}
return false
}