aLL my test cases are being passed but i am getting presentation error
import FastIO.InputReader;
import FastIO.OutputWriter;
import java.io.IOException;
public class StringPermute {
public void solve(int testNumber, InputReader in, OutputWriter out) {
String toCheck = in.readLine();
Permute permute = new Permute();
permute.permute(toCheck,0 , toCheck.length()-1);
}
}
class Permute {
void permute(String str, int l, int r) {
if(l == r) {
System.out.println(str);
}
else {
for (int i=l; i<=r; i++) {
str = swap(str,l,i);
permute(str ,l+1 ,r);
str = swap(str,l,i);
}
}
}
private String swap(String temp , int l , int i) {
char[] charArray = temp.toCharArray();
char a = charArray[l];
charArray[l] = charArray[i];
charArray[i] = a;
return String.valueOf(charArray);
}
}
I think problem is at Sopln() line but I am unable to remove it.