Skip to content

Commit 13530bc

Browse files
committed
Add comments for the permutations method
1 parent 55050a8 commit 13530bc

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎src/combinatorics/permutations.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
arr[j] = temp;
1111
}
1212

13+
/**
14+
* Finds all the permutations of given array.
15+
* Complexity O(n*n!).
16+
*
17+
* @param {Array} arr Array to find the permutations of
18+
* @param {Number} current Current element
19+
* @returns {Array} Array containing all the permutations
20+
*/
1321
function permutations(arr, current) {
1422
if (current >= arr.length) {
1523
return res.push(arr.slice());

0 commit comments

Comments
 (0)