Another Birthday Present!


import java.util.Scanner;

class Solution {
public static void main(String args[]) {

  Scanner scn = new Scanner(System.in);
  int n=scn.nextInt();
  while(t-->0){

            String str = scn.next();

            char[] charray = str.toCharArray();
            Arrays.sort(charray);

            permutationNoDuplicates(new String(charray), "");
        }

        public static void permutationNoDuplicates(String ques, String ans) {

            if (ques.length() == 0) {
                System.out.println(ans);
                return;
            }

            for (int i = 0; i < ques.length(); i++) {

                char ch = ques.charAt(i);
                String roq = ques.substring(0, i) + ques.substring(i + 1);

                boolean flag = true;

                for (int j = i + 1; j < ques.length(); j++) {
                    if (ques.charAt(j) == ch) {
                        flag = false;
                    }
                }

                if (flag)
                    permutationNoDuplicates(roq, ans + ch);
            }

        }
    
}

}
help me

@SanjeevKumarRay,
Is your doubt related to the codechef question or the question you have tagged? Can you please share a relevant problem statement to your code.

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.