//why inner goes upto s1<=length()…it should go upto s1<length() only right ?
for(String s1:rr)
{
for(int j=0;j<=s1.length();j++)
{
String s2=s1.substring(0,j)+ch+s1.substring(j);
mr.add(s2);
}
}
Inner loop in the method
No. its correct, it should be j<=s1.length() . this equals sign is important when you append the character in the last.
for eg. at certain point ch=‘a’ and s1=“bc”… then to get a permutation “bca”, j must be equal to s1.length().
Thanks
please resolve it and rate it if satisfied.
Thanks
.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.