package leetcode;

/**
 * https://leetcode.com/problems/score-of-parentheses/
 */
public class Problem856 {
    public int scoreOfParentheses(String S) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem856 prob = new Problem856();
        System.out.println(prob.scoreOfParentheses("()")); // 1
        System.out.println(prob.scoreOfParentheses("(())")); // 2
        System.out.println(prob.scoreOfParentheses("()()")); // 2
        System.out.println(prob.scoreOfParentheses("(()(()))")); // 6
    }
}

@@ -159,32 +159,557 @@
     
-// TODO%0A        return 0
+return scoreOfParentheses(S, 0, false);%0A    %7D%0A%0A    private int scoreOfParentheses(String s, int i, boolean open) %7B%0A        if (i == s.length()) %7B%0A            return 0;%0A        %7D%0A        int result = 0;%0A        if (s.charAt(i) == '(') %7B%0A            if (open) %7B%0A                result = scoreOfParentheses(s, i + 1, true);%0A            %7D else %7B%0A                result = scoreOfParentheses(s, i + 1, true);%0A            %7D%0A        %7D else %7B // s.charAt(i) == ')'%0A            result = scoreOfParentheses(s, i + 1, false) + 1;%0A        %7D%0A        return result
 ;%0A  
@@ -802,16 +802,18 @@
 m856();%0A
+//
         
@@ -868,16 +868,18 @@
 ); // 1%0A
+//
         
@@ -928,32 +928,174 @@
 (%22(())%22)); // 2%0A
+//        System.out.println(prob.scoreOfParentheses(%22()()()%22)); // 3%0A//        System.out.println(prob.scoreOfParentheses(%22(())()%22)); // 3%0A//
         System.o
@@ -1144,16 +1144,18 @@
 ); // 2%0A
+//
         
@@ -1216,16 +1216,231 @@
 ); // 6%0A
+//        System.out.println(prob.scoreOfParentheses(%22((()))%22)); // 4%0A//        System.out.println(prob.scoreOfParentheses(%22((()()))%22)); // 8%0A        System.out.println(prob.scoreOfParentheses(%22((()())())%22)); // 10%0A
     %7D%0A%7D%0A

Update problem 856