We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parente88daad commitad11b79Copy full SHA for ad11b79
permutations-ii/Solution.java
@@ -1,4 +1,5 @@
1
publicclassSolution {
2
+
3
voidswap(intx[],inta,intb) {
4
intt =x[a];
5
x[a] =x[b];
@@ -37,19 +38,18 @@ public boolean nextPermutation(int[] num) {
37
38
returntrue;
39
}
40
-ArrayList<Integer>asList(int[]num){
41
+List<Integer>asList(int[]num){
42
ArrayList<Integer>l =newArrayList<Integer>(num.length);
43
for(inti =0;i <num.length;i++)
44
l.add(num[i]);
45
46
returnl;
47
48
-publicArrayList<ArrayList<Integer>>permuteUnique(int[]num) {
49
-// Note: The Solution object is instantiated only once and is reused by each test case.
+publicList<List<Integer>>permuteUnique(int[]num) {
50
Arrays.sort(num);
51
52
-ArrayList<ArrayList<Integer>>found =newArrayList<ArrayList<Integer>>();
+ArrayList<List<Integer>>found =newArrayList<List<Integer>>();
53
found.add(asList(num));
54
55
while(nextPermutation(num)){
@@ -58,4 +58,4 @@ public ArrayList<ArrayList<Integer>> permuteUnique(int[] num) {
58
59
returnfound;
60
61
-}
+}