-
Notifications
You must be signed in to change notification settings - Fork 0
293. Flip Game
PuChen0211 edited this page Jun 30, 2016
·
3 revisions
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;
}