File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 1313class BeautifulArrange :
1414 # funtion call; n is the size of the permutation (numbers 1..n)
1515 def countarrangement (self , n : int ) -> int :
16-
1716 self .count = 0
1817 """
19- We initialize a counter to record how many valid arrangements we find.
18+ We initialize a counter to record how many valid arrangements we find.
2019 Using self.count lets the nested function modify it without nonlocal.
2120 """
22-
21+
2322 used = [False ] * (n + 1 )
2423 """
25- A boolean list to mark which numbers have
24+ A boolean list to mark which numbers have
2625 already been placed in the permutation.
2726 """
2827
@@ -33,7 +32,7 @@ def backtrack(pos):
3332 We try to assign a number to position pos.
3433 """
3534 if pos > n :
36- self .count += 1
35+ self .count += 1
3736 # We found a complete valid arrangement, so increment the total count.
3837 return
3938 for num in range (
You can’t perform that action at this time.
0 commit comments