我无法理解作者如何得到O(n^2 * n!) 以下过程的复杂性,该过程生成字符串的所有排列.
void permutation(String str){
permutation(str,"");
}
void permutation(String str, String prefix){
if(str.length()==0){
System.out.println(prefix);
} else{
for(int i=0;i<str.length();i++){
String rem=str.substring(0,i)+str.substring(i+1);
permutation(rem,prefix+str.charAt(i));
}
}
}
Run Code Online (Sandbox Code Playgroud)