Leetcode 294 Solution
This article provides solution to leetcode question 294 (flip-game-ii)
Access this page by simply typing in "lcs 294" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/flip-game-ii
Solution
class Solution {
public:
bool canWin(string s) {
for (int i = 0; i + 1 < s.size(); i++)
{
if (s[i] == '+' && s[i + 1] == '+')
{
s[i] = s[i + 1] = '-';
bool win = canWin(s);
s[i] = s[i + 1] = '+';
if (win == false)
return true;
}
}
return false;
}
};