diff --git a/data/leetCode Solutions/Q47_Permutations_II/Q47_Permutations_II.java b/data/leetCode Solutions/Q47_Permutations_II/Q47_Permutations_II.java new file mode 100644 index 0000000..e68edea --- /dev/null +++ b/data/leetCode Solutions/Q47_Permutations_II/Q47_Permutations_II.java @@ -0,0 +1,44 @@ +class Solution { + + public void helper(int posi, int n, int[] nums, List> ans){ + + if(posi>=n){ + List permutations= convertToArray(nums); + ans.add(new ArrayList(permutations)); + return; + } + + HashSet set= new HashSet<>(); + + for(int i=posi; i convertToArray(int[] nums){ + List ans= new ArrayList<>(); + for(int ele:nums){ + ans.add(ele); + } + return ans; + } + + public List> permuteUnique(int[] nums) { + List> ans= new ArrayList<>(); + helper(0, nums.length, nums, ans); + return ans; + } +} \ No newline at end of file