> For the complete documentation index, see [llms.txt](https://851958789.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://851958789.gitbook.io/notes/1111_maximum_nesting_depth_of_two_valid_parentheses_strings/slt.md).

# 思路1

把左括号按深度分别分给A和B，这样让A和B相差的高度尽可能小。总高度也就会越小。

// 让A字符串和B字符串的depth尽可能的接近。 // 为什么呢？因为seq对应的栈上，每个左括号都对应一个深度，而这个左括号，要么是A的，要么是B的。 // 所以，栈上的左括号只要按奇偶分配给A和B就可以啦！

输入：seq = "()(())()" 输出：\[0,0,0,1,1,0,1,1] 解释：本示例答案不唯一。 按此输出 A = "()()", B = "()()", max(depth(A), depth(B)) = 1，它们的深度最小。 像 \[1,1,1,0,0,1,1,1]，也是正确结果，其中 A = "()()()", B = "()", max(depth(A), depth(B)) = 1 。
