Question 2 Generate All Valid Parentheses III
Last updated
Last updated
public class Solution {
private static final char[] allP = {
'(', ')', '<', '>', '{', '}',
}
public List<String> ValidParenthese(int l, int m, int n) {
List<String> result = new ArrayList<>();
Map<Character, Integer> priority = new HashMap<>();
priorty.put("(", 0);
priorty.put("<", 1);
priorty.put("{", 2);
StringBuilder sb = new StringBuilder();
Deque<Character> stack = new ArrayQueue<>();
int[] remain = {l, l, m, m, n ,n};
int total = 2 * l + 2 * m + 2 * n;
DFS(remain, result, total, sb, stack, priority);
return result;
}
}