You are viewing a single comment's thread. Return to all comments →
my function passes twenty test cases and fail in the rest can someone tell me what's wrong with it
void noPrefix(vector<string> words) { int letterCount = 0; for (int i = 0; i < words.size(); i++) { int j = 0; int k = 0; int z = 0; while (z < i) { if (j < words[z].size() && k < words[i].size()) { if (words[z][j] == words[i][k]) { letterCount++; j++; k++; if (letterCount == words[z].size() || letterCount == words[i].size()) { cout << "BAD SET\n"<< words[i]; return; } } else { letterCount = 0; j = 0; k++; } } else { letterCount = 0; j = 0; k = 0; z++; } }
} cout << "GOOD SET\n";
} `
No Prefix Set
You are viewing a single comment's thread. Return to all comments →
my function passes twenty test cases and fail in the rest can someone tell me what's wrong with it
} `