Skip to content

Update permutations.py #8102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 31, 2023
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 17, 2023
commit 64f0654deb4dd88638cee1de0024b393a040d26f
2 changes: 2 additions & 0 deletions data_structures/arrays/permutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def permute2(nums):
>>> permute2([1, 2, 3])
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2]]
"""

def backtrack(start):
if start == len(nums) - 1:
output.append(nums[:])
Expand All @@ -42,6 +43,7 @@ def backtrack(start):

if __name__ == "__main__":
import doctest

# use res to print the data in permute2 function
res = permute2([1, 2, 3])
print(res)
Expand Down