Please discuss the algorithm?

I am not able to think the algorithm for this ques ,kindly discuss it

Hello @namangarg31,

The logic is same as that for finding all the permutations of a string.
But with an additional conditional check in the base case to check if the current permutation is larger than the given string or not.

Yes, you can approach this question in different ways.

Approach 1:

Coding Blocks IDE

Coding Blocks IDE

Coding Blocks Online IDE | Run and check your code

Approach 2:

Coding Blocks IDE

Coding Blocks IDE

Coding Blocks Online IDE | Run and check your code

But the above mentioned two approaches are similar in one or the other way.

Hope, this would help.
Give a like if you are satisfied.

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.