Interview Algorithms: Difference between revisions

Line 22: Line 22:
Print all permutations of an array.<br>
Print all permutations of an array.<br>
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 element 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>
* [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]