Fix 303、307、167、653、1017 multi ‘--’ cause link bad

This commit is contained in:
YDZ
2021-02-26 21:38:26 +08:00
parent c839a96874
commit b4eab90b74
37 changed files with 329 additions and 317 deletions

View File

@ -1,17 +1,13 @@
package leetcode
import "fmt"
func validateStackSequences(pushed []int, popped []int) bool {
stack, j, N := []int{}, 0, len(pushed)
for _, x := range pushed {
stack = append(stack, x)
fmt.Printf("stack = %v j = %v\n", stack, j)
for len(stack) != 0 && j < N && stack[len(stack)-1] == popped[j] {
stack = stack[0 : len(stack)-1]
j++
}
fmt.Printf("*****stack = %v j = %v\n", stack, j)
}
return j == N
}