permutations
-
[Algo Rhythm🕺💃] LeetCode 46. PermutationsAlgo Rhythm🕺💃/LeetCode 2020. 8. 22. 22:35
📚 Problem description 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] ] 🎯 Solution class Solution { List ans = new ArrayList(); public List permute(int[] nums) { boolean[] visited = new boolean[nums.length]; backtrack(nums, visited, new ArrayList()); return ans; } public void backtra..