题目:
解法:
Set<List<Character>> getAllSubSet(String str, int digits) {
// check the input
if (str.matches("[^0-9]") || digits > str.length()) {throw new IllegalArgumentException("Invalid input");}
// put every subSet into result
Set<List<Character>> result = new HashSet<>();
for (int i = 0; i < (str.length() - digits + 1); i++) {
List<Character> subSet = new ArrayList<>();
for (int j = 0; j < digits; j++) {
subSet.add(str.charAt(i + j));
}
result.add(subSet);
}
return result;
}