-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
26 lines (23 loc) · 776 Bytes
/
Solution.java
File metadata and controls
26 lines (23 loc) · 776 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
class Solution {
public List<String> letterCasePermutation(String S) {
Set<String> res = new HashSet<String>();
for (char c : S.toCharArray()) {
String s = String.valueOf(c);
if (res.size() == 0) {
res.add(s.toUpperCase());
res.add(s.toLowerCase());
} else {
Set<String> temp = new HashSet<String>();
for (String v : res) {
temp.add(v + s.toUpperCase());
temp.add(v + s.toLowerCase());
}
res = temp;
}
}
res.add(S);
List<String> result = new ArrayList<String>();
result.addAll(res);
return result;
}
}