File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 1010"""
1111# Solution using Backtracking
1212
13+
1314class beautifularrange :
1415 # funtion call; n is the size of the permutation (numbers 1..n)
1516 def countarrangement (self , n : int ) -> int :
16-
1717 self .count = 0
1818 """
19- We initialize a counter to record how many valid arrangements we find.
19+ We initialize a counter to record how many valid arrangements we find.
2020 Using self.count lets the nested function modify it without nonlocal.
2121 """
22-
22+
2323 used = [False ] * (n + 1 )
2424 """
25- A boolean list to mark which numbers have
25+ A boolean list to mark which numbers have
2626 already been placed in the permutation.
2727 """
2828
@@ -33,7 +33,7 @@ def backtrack(pos):
3333 We try to assign a number to position pos.
3434 """
3535 if pos > n :
36- self .count += 1
36+ self .count += 1
3737 # We found a complete valid arrangement, so increment the total count.
3838 return
3939 for num in range (
You can’t perform that action at this time.
0 commit comments