data_structures.arrays.permutations

Attributes

result

Functions

permute_backtrack(→ list[list[int]])

Return all permutations of the given list.

permute_recursive(→ list[list[int]])

Return all permutations.

Module Contents

data_structures.arrays.permutations.permute_backtrack(nums: list[int]) list[list[int]]

Return all permutations of the given list.

>>> permute_backtrack([1, 2, 3])
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2]]
data_structures.arrays.permutations.permute_recursive(nums: list[int]) list[list[int]]

Return all permutations.

>>> permute_recursive([1, 2, 3])
[[3, 2, 1], [2, 3, 1], [1, 3, 2], [3, 1, 2], [2, 1, 3], [1, 2, 3]]
data_structures.arrays.permutations.result