What is wrong in my code

public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int n =sc.nextInt();
for(int i=0;i<n;i++) {
String s=sc.next();
fun("", 0, s.length(), s);

	}

	
}
public static void fun(String t ,int i,int n,String s) {
	if(i==n) {
		System.out.println(t);
		return;
	}
	else {
		fun(t, i+1, n, s);
		t=t+s.charAt(i);
		fun(t, i+1, n, s);
	}
	
}

}

@deepgarg46 You have to print the subsequences in Lexicographical order. So you have two ways :
Either Sort your string before getting all subsequence or you can store all your subsequences in array and then sort the array and print it. The latter way is preferred.

i have to write a separate fun for comparation?

@deepgarg46 You can use anything you want. You just need to sort the array by any method.

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.