💡 Recursion-Dictionary Order(Larger) Problen

On One test case i am getting wrong anwer
can you help me !
Submission #3095771

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class RecursionChallenge {

public static void main(String[] args) {
	// TODO Auto-generated method stub

	Scanner s = new Scanner(System.in);
	String str= s.nextLine();
	ArrayList<String> mylist=RecursionDictionary(str);
	//System.out.println(mylist);
	for(int i=0;i<mylist.size();i++)
	{
		String mystring=mylist.get(i);
		for(int j=0;j<str.length();j++)
		{
			if(mystring.charAt(j)<str.charAt(j))
			break;
			else if(mystring.charAt(j)>str.charAt(j))
			{
				System.out.println(mystring);
				break;
			}
			else if(mystring.charAt(j)==str.charAt(j))
			continue;
		}
	}
	
   
}

public static ArrayList<String> RecursionDictionary(String str)	
{
	
	if(str.length()==1)
	{
		ArrayList<String> list= new ArrayList<String>();
		list.add(""+str.charAt(0));
		return list;
	}
	char cc= str.charAt(0);
	String RestOfString= str.substring(1);
	ArrayList<String> myresult= new ArrayList<String>();
	ArrayList<String> RecResult= RecursionDictionary(RestOfString);
	
	for(int i=0;i<RecResult.size();i++)
	{
		String Recstr=RecResult.get(i);
		for(int j=0;j<=Recstr.length();j++)
		{
			myresult.add(Recstr.substring(0,j)+cc+Recstr.substring(j));
		}
	}
	return myresult;
}

}

Your approach is not wrong, but the question asks you to recursively print all permutations of the string greater than the original. Since you are finding all permutations and then iteratively printing the greater ones, the order of printing does not match the order in the output. That is why the test case is failing. Try to think of an approach where you can do the complete work recursively, including the comparison. As a hint, you can keep a parameter “String original” in your recursive function and compare it with every permutation in the base case. Keep the return type of the function as void, and keep printing the appropriate permutations as you find them.

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.