public List<String> permutation(List<String> list, String target, String ans){
if(target.length() <= 1) {
list.add(ans + target);
} else {
for (int i = 0; i < target.length(); i++) {
permutation(
list,
target.substring(0, i) + target.substring(i + 1),
ans + target.charAt(i));
}
}
return list;
}
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
31