mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
841ca3d660
commit
606f962196
|
@ -1,5 +1,6 @@
|
|||
from itertools import combinations
|
||||
|
||||
|
||||
def permute_recursive(nums: list[int]) -> list[list[int]]:
|
||||
"""
|
||||
Return all permutations.
|
||||
|
@ -19,6 +20,7 @@ def permute_recursive(nums: list[int]) -> list[list[int]]:
|
|||
nums.append(n)
|
||||
return result
|
||||
|
||||
|
||||
def permute_backtrack(nums: list[int]) -> list[list[int]]:
|
||||
"""
|
||||
Return all permutations of the given list.
|
||||
|
@ -26,6 +28,7 @@ def permute_backtrack(nums: list[int]) -> list[list[int]]:
|
|||
>>> permute_backtrack([1, 2, 3])
|
||||
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2]]
|
||||
"""
|
||||
|
||||
def backtrack(start: int) -> None:
|
||||
if start == len(nums) - 1:
|
||||
output.append(nums[:])
|
||||
|
@ -39,6 +42,7 @@ def permute_backtrack(nums: list[int]) -> list[list[int]]:
|
|||
backtrack(0)
|
||||
return output
|
||||
|
||||
|
||||
def get_combinations(nums: list[int], r: int) -> list[list[int]]:
|
||||
"""
|
||||
Return all combinations of the given list of length r.
|
||||
|
|
Loading…
Reference in New Issue
Block a user