题目:
解法:
Set
<List
<Character>> getAllSubSet(String str
, int digits
) {
if (str
.matches("[^0-9]") || digits
> str
.length()) {throw new IllegalArgumentException("Invalid input");}
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
;
}
转载请注明原文地址: https://lol.8miu.com/read-7267.html