293. Flip Game - cocoder39/coco39_LC GitHub Wiki
for (int i = 0; i < s.length() - 1; i++)
would generate run time error when test case is s = ""
. Because s.length()
is unsigned int
vector<string> generatePossibleNextMoves(string s) {
vector<string> res;
for (int i = 0; i < (int)s.length() - 1; i++) {
if (s[i] == '+' && s[i + 1] == '+') {
s[i] = '-';
s[i + 1] = '-';
res.push_back(s);
s[i] = '+';
s[i + 1] = '+';
}
}
return res;
}