MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / function

Method function

java/0046-permutations.java:12–25  ·  view source on GitHub ↗
(List<List<Integer>> ans, int[] arr, int start)

Source from the content-addressed store, hash-verified

10 }
11
12 public void function(List<List<Integer>> ans, int[] arr, int start) {
13 if (start == arr.length) {
14 List<Integer> list = new ArrayList();
15 for (int i = 0; i < arr.length; i++) list.add(arr[i]);
16 ans.add(list);
17 return;
18 }
19
20 for (int i = start; i < arr.length; i++) {
21 swap(arr, start, i);
22 function(ans, arr, start + 1);
23 swap(arr, start, i);
24 }
25 }
26
27 public void swap(int[] arr, int a, int b) {
28 int temp = arr[a];

Callers 1

permuteMethod · 0.95

Calls 2

swapMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected