Given a collection of distinct integers, return all possible permutations.
Example: Input: [1,2,3] Output: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] The solution for this problem can be solved in 2 ways: 1. Using recursion 2. Using next permutation. 3. Using Heap’s algorithm < https://en.wikipedia.org/wiki/Heap%27s_algorithm> First we shall look at the code, later I shall explain about the working of all three the solutions … Continue reading Given a collection of distinct integers, return all possible permutations.
Copy and paste this URL into your WordPress site to embed
Copy and paste this code into your site to embed