当前位置:网站首页>LeetCode+ 46 - 50

LeetCode+ 46 - 50

2022-06-22 01:50:00 Sauerkraut

Full Permutation

Algorithm tags : Array 、 to flash back

Give us a sequence of numbers without repeating numbers , Let's find its total permutation

The implementation of recursive search

Search in what order , There are many search orders for ranking problems

We can enumerate which number to fill in for each position from front to back , You can enumerate which number to fill in the first position , Then enumerate which number to fill in the second position , And so on

② Enumerate the position of each number in turn , The first number can be placed on the 0 In a position , You can put it in the 1 You can also put it in the... Position 2 In a position , The second number can be put in the 0 In a position , You can put it in the 1 You can also put it in the... Position 2 In a position

For the permutation problem , The above two search orders are OK

The recursive search tree of the first scheme is given below , Each leaf node represents a scheme

原网站

版权声明
本文为[Sauerkraut]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220116105983.html