## [f]izzbuzzer

### Looking for good programming challenges?

Use the search below to find our solutions for selected questions!

# All posts tagged permutations

### Permutations II

Problem statement Given a list, nums, of distinct numbers, return all possible unique permutations. Sample input [1,2,1] Sample output [[1, 2, 1], [2, 1, 1], [1, 1, 2]] Solution In another post we showed how this problem can be solved iteratively. We can use the same technique but add a . . . Read more

### Permutations challenge – Iterative solution

Problem statement Given a list, nums, of distinct numbers, return all possible permutations. Sample input [1,2,3] Sample output [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] Solution In another post we showed how this problem can be solved using a recursive technique by swapping. We stumbled upon a nice iterative . . . Read more

### Permutations challenge

Problem statement Given a list, nums, of distinct numbers, return all possible permutations. Sample input [1,2,3] Sample output [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] Solution We are using a technique called permutations by swapping. Full code class Solution(object): def swap(self, nums, i, j): tmp = nums[i] nums[i] = . . . Read more