DFS Full Permutation


Update the understanding of Full Permutation recursive method

U is a local variable, which is used to point to the elements of each permutation sequence
ST is a global variable array, which can ensure that each individual line does not repeat

As shown in the figure above, initially u traverses from 1 to n (1, 2 and 3 in the first line), but when pointing to 1, u needs to go to the depth first. When reaching the next layer, it wants to go to the right (1, 2, – > 1, 3,), but it needs to go to the next layer first, and it can’t go back until the last layer.

using namespace std;

int n, e[8], path[8], idx = 0;
bool st[8];

void dfs(int u){
    if(u == n){
        for(int i=0; i> n;
    return 0;