Skip to content

Commit

Permalink
Update flip-game.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
kamyu104 committed Oct 15, 2015
1 parent acf237d commit a9e400e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions C++/flip-game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
vector<string> generatePossibleNextMoves(string s) {
vector<string> res;
int n = s.length();
for (int i = 0; i < n - 1; ++i) {
for (int i = 0; i < n - 1; ++i) { // n times
if (s[i] == '+') {
for (;i < n - 1 && s[i + 1] == '+'; ++i) {
s[i] = s[i + 1] = '-';
res.emplace_back(s);
res.emplace_back(s); // O(n) to copy a string
s[i] = s[i + 1] = '+';
}
}
Expand Down

0 comments on commit a9e400e

Please sign in to comment.