标签:highlight etc split code UNC range ++ end for
这道题主要是读题意,但是问题是题意翻译的很差劲,而且这道题并没有唯一期望。
至于读懂题意后的代码,就很简单了。
func maxDepthAfterSplit(seq string) []int {
depth := 0
var ans []int
for _, c := range seq {
if c == ‘(‘ {
depth++
ans = append(ans, depth % 2)
} else {
ans = append(ans, depth % 2)
depth--
}
}
return ans
}
end
标签:highlight etc split code UNC range ++ end for
原文地址:https://www.cnblogs.com/CherryTab/p/12616893.html