mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-09 15:59:06 +01:00
go: add «334. Increasing Triplet Sequence»
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
3c34c8b3db
commit
4bf8cc35ee
1 changed files with 18 additions and 0 deletions
18
go/increasing-triplet-subsequence.go
Normal file
18
go/increasing-triplet-subsequence.go
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
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
|
||||||
|
}
|
Loading…
Reference in a new issue