add new solutions
This commit is contained in:
parent
886b5e0a8e
commit
67cad91898
47 changed files with 1549 additions and 1 deletions
24
solutions/3/q334/solution.go
Normal file
24
solutions/3/q334/solution.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue