Skip to content

Commit 2e68100

Browse files
authored
Update guess-the-word.cpp
1 parent 007885a commit 2e68100

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

C++/guess-the-word.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ class Solution {
3232
int find_guess_with_most_frequent_chars(
3333
const vector<string>& wordlist,
3434
const vector<int>& possible) {
35-
vector<int> count(26);
35+
vector<vector<int>> count(6, vector<int>(26));
3636
for (int i = 0; i < 6; ++i) {
3737
for (const auto& p : possible) {
38-
++count[wordlist[p][i] - 'a'];
38+
++count[i][wordlist[p][i] - 'a'];
3939
}
4040
}
4141
int guess = 0, max_score = 0;
4242
for (const auto& p : possible) {
4343
int score = 0;
4444
for (int i = 0; i < 6; ++i) {
45-
score += count[wordlist[p][i] - 'a'];
45+
score += count[i][wordlist[p][i] - 'a'];
4646
}
4747
if (score > max_score) {
4848
max_score = score;

0 commit comments

Comments
 (0)