package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/
 */
public class Problem1111 {
    public int[] maxDepthAfterSplit(String seq) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1111 prob = new Problem1111();
        System.out.println(Arrays.toString(prob.maxDepthAfterSplit("(()())"))); // [0,1,1,1,1,0]
        System.out.println(Arrays.toString(prob.maxDepthAfterSplit("()(())()"))); // [0,0,0,1,1,0,1,1]
        System.out.println(Arrays.toString(prob.maxDepthAfterSplit("()(()())"))); // [0,0,0,1,0,0,0,1]
    }
}

@@ -29,22 +29,21 @@
 va.util.
-Arrays
+Stack
 ;%0A%0A/**%0A 
@@ -223,133 +223,254 @@
     
-// TODO%0A        return null;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1111 prob = new Problem1111
+int%5B%5D answer = new int%5Bseq.length()%5D;%0A        int level = 0;%0A        int max = 0;%0A        Stack%3CInteger%3E startIndexes = new Stack%3C%3E();%0A        // index: start index%0A        // value: end index%0A        Integer%5B%5D indexes = new Integer%5Bseq.length
 ()
+%5D
 ;%0A  
@@ -479,302 +479,792 @@
     
-System.out.println(Arrays.toString(prob.maxDepthAfterSplit(%22(()())%22))); // %5B0,1,1,1,1,0%5D%0A        System.out.println(Arrays.toString(prob.maxDepthAfterSplit(%22()(())()%22))); // %5B0,0,0,1,1,0,1,1%5D%0A        System.out.println(Arrays.toString(prob.maxDepthAfterSplit(%22()(()())%22))); // %5B0,0,0,1,0,0,0,1%5D
+for (int i = 0; i %3C seq.length(); i++) %7B%0A            if (seq.charAt(i) == '(') %7B%0A                startIndexes.push(i);%0A                level++;%0A                max = Math.max(max, level);%0A            %7D else %7B // ')'%0A                indexes%5BstartIndexes.pop()%5D = i;%0A                level--;%0A            %7D%0A        %7D%0A        int half = max / 2;%0A        level = 0;%0A        for (int i = 0; i %3C seq.length(); i++) %7B%0A            if (seq.charAt(i) == '(') %7B%0A                level++;%0A                if (level %3C= half) %7B%0A                    if (indexes%5Bi%5D != null) %7B%0A                        answer%5Bi%5D = 1;%0A                        answer%5Bindexes%5Bi%5D%5D = 1;%0A                    %7D%0A                %7D%0A            %7D else %7B // ')'%0A                level--;%0A            %7D%0A        %7D%0A        return answer;
 %0A   

Solve problem 1111