MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / backtrack

Function backtrack

data_structures/arrays/permutations.py:29–36  ·  view source on GitHub ↗
(start: int)

Source from the content-addressed store, hash-verified

27 """
28
29 def backtrack(start: int) -> None:
30 if start == len(nums) - 1:
31 output.append(nums[:])
32 else:
33 for i in range(start, len(nums)):
34 nums[start], nums[i] = nums[i], nums[start]
35 backtrack(start + 1)
36 nums[start], nums[i] = nums[i], nums[start] # backtrack
37
38 output: list[list[int]] = []
39 backtrack(0)

Callers 1

permute_backtrackFunction · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected