# Question

Formatted question description: https://leetcode.ca/all/1111.html




# Algorithm

( ( ) ) ( )
0 1 2 3 4 5


0,3 and 4,5 are brackets at the same level, so that the depth of the two parts is 1, and the absolute value of the difference is 0

But if 0, 3 and 1, 2 are put in a group, then the depth of this part is 2, and the depth of the other part is 1, and the absolute value of the difference between the two parts is 1.

# Code

Java

Java

class Solution {
public int[] maxDepthAfterSplit(String seq) {
int length = seq.length();
int[] depths = new int[length];
int curDepth = -1;
for (int i = 0; i < length; i++) {
if (seq.charAt(i) == '(')
depths[i] = ++curDepth;
else
depths[i] = curDepth--;
}
int[] split = new int[length];
for (int i = 0; i < length; i++)
split[i] = depths[i] % 2;
return split;
}
}