25 lines
431 B
Go
25 lines
431 B
Go
// Package q334 implements a solution for https://leetcode.com/problems/increasing-triplet-subsequence/
|
|
package q334
|
|
|
|
import "math"
|
|
|
|
func increasingTriplet(nums []int) bool {
|
|
if len(nums) < 3 {
|
|
return false
|
|
}
|
|
|
|
first, second := math.MaxInt, math.MaxInt
|
|
|
|
for _, x := range nums {
|
|
if x <= first {
|
|
first = x
|
|
} else if x <= second {
|
|
second = x
|
|
} else {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
var _ = increasingTriplet
|