MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / validParens

Function validParens

generate_parentheses_22/solution.go:25–38  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

23}
24
25func validParens(s string) bool {
26 stack := make([]string, len(s))
27 top := 0
28 for i := 0; i < len(s); i++ {
29 if top > -1 && string(s[i]) == "(" {
30 stack[top] = string(s[i])
31 top++
32 } else if string(s[i]) == ")" {
33 top--
34 }
35 }
36
37 return top == 0
38}

Callers 1

genPFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected