Horje
find all permutations of a string Code Example
python all permutations of a string
>>> from itertools import permutations
>>> perms = [''.join(p) for p in permutations('stack')]
>>> perms
find all permutations of a string
void permute(string a, int l, int r)  
{  
    // Base case  
    if (l == r)  
        cout<<a<<endl;  
    else
    {  
        // Permutations made  
        for (int i = l; i <= r; i++)  
        {  
  
            // Swapping done  
            swap(a[l], a[i]);  
  
            // Recursion called  
            permute(a, l+1, r);  
  
            //backtrack  
            swap(a[l], a[i]);  
        }  
    }  
}  
how to print all permutations of a string
void permutation(string s)
{
    sort(s.begin(),s.end());
	do{
		cout << s << " ";
	}
    while(next_permutation(s.begin(),s.end()); // std::next_permutation
    
    cout << endl;
}
find permutations
void find_permutations(vector<int> &array, size_t index, vector<int> current_perm, vector<vector<int>> &res){
    if(index == array.size()) 
        res.push_back(current_perm);
    else{
        for(size_t i = 0; i <= current_perm.size(); ++i){
            vector<int> new_perm(current_perm.begin(), current_perm.end());
            new_perm.insert(new_perm.begin()+i, array[index]);
            find_permutations(array, index+1, new_perm, res);
        }
    }
}




Whatever

Related
Get width of screen Code Example Get width of screen Code Example
social engineering toolkit Code Example social engineering toolkit Code Example
ignore cypress from linter Code Example ignore cypress from linter Code Example
change next port Code Example change next port Code Example
go proxy Code Example go proxy Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7