diff --git a/Java/Perm_Recus.java b/Java/Perm_Recus.java new file mode 100644 index 00000000..40b3a9a6 --- /dev/null +++ b/Java/Perm_Recus.java @@ -0,0 +1,32 @@ +public List> permute(int[] nums) { + List> result = new ArrayList<>(); + helper(0, nums, result); + return result; +} + +private void helper(int start, int[] nums, List> result) +{ + if(start==nums.length-1){ + ArrayList list = new ArrayList<>(); //if starting value(say n) is the last value , this will make a new list with the values and the new starting value is n + for(int num: nums) + { + list.add(num); + } + result.add(list); + return; + } + + for(int i=start; i [Sample PR](https://github.com/codedecks-in/LeetCode-Solutions/pu | 189 | [Rotate-Array](https://leetcode.com/problems/rotate-array/) | [Python](./Python/rotate-array.py) | O(N) | O(1) | Medium | Array | | 496 | [next-greater-element-i](https://leetcode.com/problems/next-greater-element-i) | [Python](./Python/496_nextgreaterelement.py) | O(N) | O(1) | Medium | Array | | 1470 | [Shuffle the Array](https://leetcode.com/problems/shuffle-the-array) | [Java](./Java/shuffle-the-array.java) | O(N) | O(1) | Easy | Array | +| 124 | [Permutation by Recussion](https://leetcode.com/problems/permutations/) | [Java](./Java/shuffle-the-array.java) | O(N) | O(N) | Easy | Array | | 283 | [Move-Zeroes](https://leetcode.com/problems/move-zeroes/) | [C++](./C++/Move-Zeroes.cpp) | O(N) | O(1) | Easy | Array | | 27 | [Remove-Element](https://leetcode.com/problems/remove-element/) | [C++](./C++/remove-element.cpp) | O(N) | O(1) | Easy | Array | -