For this Question: A ​ permutation is simply a name for a reordering. So the permutations of the string
‘abc’ are ‘abc’, ‘acb’, ‘bac’, ‘bca’, ‘cab’, and ‘cba’. Note that a sequence is a
permutation of itself (the trivial permutation). For this problem, you’ll need
to write a ​ recursive​ function ​​ that takes a string and returns a
list of all its permutations.
A couple of notes on the requirements:
1. The order of the returned permutations must be lexicographically.
2. Avoid returning duplicates in your final list.Input contains a single string S.

Constraints:-
1<=|S|<=8Print all the permutations of string S in lexicographical order.Sample Input: 
ABC

Sample Output :
ABC ACB BAC BCA CAB CBA

Explanation:
all permutation are arranged in lexicographical order .

Sample Input:
(T(

Sample Output:-
((T (T( T((, I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;
set<string> se;
// Function to find all Permutations of a given string
// containing all distinct characters
void permutations(string str, int n, string res)
{
	// base condition (only one character is left in the string)
	if (n == 1)
	{
		string s= res + str;
		se.insert(s);
		return;
	}

	// process each character of the remaining string
	for (int i = 0; i < n; i++)
	{
		// push current character to the output string and recur
		// for the remaining characters
		permutations(str.substr(1), n - 1, res + str[0]);

		// left rotate the string by 1 unit for next iteration
		// to right rotate the string use reverse iterator
		rotate(str.begin(), str.begin() + 1, str.end());
	}
}

// Find all Permutations of a string
int main()
{

	string s;
	cin>>s;

string res="";
	permutations(s, s.size(), res);
for(auto it=se.begin();it!=se.end();it++){
    cout<<*it<<" ";
}
	return 0;
}
, In this Programming Language: C++, Now tell me if this Code is compilable or not?