-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution22.java
More file actions
32 lines (22 loc) · 810 Bytes
/
Copy pathSolution22.java
File metadata and controls
32 lines (22 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package leecode;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
public class Solution22 {
public static void main(String[] args) {
Solution22 s = new Solution22();
List<String> r;
r = s.generateParenthesis(1);
assert r.size()==1&&r.get(0).equals("()");
r = s.generateParenthesis(3);
HashSet<String> set = new HashSet<>(Arrays.asList("((()))", "(()())", "(())()", "()(())", "()()()"));
assert r.size()==5&& set.containsAll(r);
}
public List<String> generateParenthesis(int n) {
char[] chars = new char[n +n];
for (int i = 0; i < n; i++) chars[i]='(';
for (int i = n; i < chars.length; i++) chars[i]=')';
return Collections.emptyList();
}
}