HTMLify

LeetCode - Maximum Nesting Depth of the Parentheses - Go
Views: 41 | Author: abh
func maxDepth(s string) int {
    var depth, max_depth int
    for _, c := range s {
        if c == '(' {
            depth++
        }
        if c == ')' {
            depth--
        }
        if depth > max_depth {
            max_depth = depth
        }
    }
    return max_depth
}

Comments