@@ -12,19 +12,19 @@ def maxScoreWords(self, words, letters, score):
12
12
:type score: List[int]
13
13
:rtype: int
14
14
"""
15
- def backtracking (words , word_scores , word_counts , curr , curr_score , count , result ):
15
+ def backtracking (words , word_scores , word_counts , curr , curr_score , letter_count , result ):
16
16
result [0 ] = max (result [0 ], curr_score )
17
17
for i in xrange (curr , len (words )):
18
- if any (count [c ] < word_counts [i ][c ] for c in word_counts [i ]):
18
+ if any (letter_count [c ] < word_counts [i ][c ] for c in word_counts [i ]):
19
19
continue
20
20
backtracking (words , word_scores , word_counts , i + 1 ,
21
- curr_score + word_scores [i ], count - word_counts [i ],
21
+ curr_score + word_scores [i ], letter_count - word_counts [i ],
22
22
result )
23
23
24
24
result = [0 ]
25
- count = collections .Counter (letters )
25
+ letter_count = collections .Counter (letters )
26
26
word_counts = map (collections .Counter , words )
27
27
word_scores = [sum (score [ord (c )- ord ('a' )] for c in words [i ])
28
28
for i in xrange (len (words ))]
29
- backtracking (words , word_scores , word_counts , 0 , 0 , count , result )
29
+ backtracking (words , word_scores , word_counts , 0 , 0 , letter_count , result )
30
30
return result [0 ]
0 commit comments