This commit is contained in:
VicRen
2020-12-21 20:25:53 +08:00
parent 7fd2ca728a
commit 5b9710bf17
2 changed files with 62 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
package main
func main() {
}
func isMountain(nums []int) bool {
hasUp := false
hasDown := false
c := nums[0]
for i := 0; i < len(nums); i++ {
n := nums[i]
if !hasUp && !hasDown && n > c {
hasUp = true
}
if c > n {
hasDown = true
}
if n > c && hasDown {
return false
}
c = n
}
return hasDown && hasUp
}