5,322
edits
Line 23: | Line 23: | ||
The idea here is that you need a for-loop nested for each element of an array.<br> | The idea here is that you need a for-loop nested for each element of an array.<br> | ||
So n elements means n nested for-loops. You use recursion to nest the loops.<br> | So n elements means n nested for-loops. You use recursion to nest the loops.<br> | ||
You can also think of this as a graph problem when you need to find every possible path with DFS.<br> | |||
* [https://leetcode.com/problems/permutations/ Permutations] | * [https://leetcode.com/problems/permutations/ Permutations] | ||
* [https://leetcode.com/problems/permutations-ii/ Permutations-iii] | * [https://leetcode.com/problems/permutations-ii/ Permutations-iii] |