[LeetCode294] Flip Game II
来源:互联网 发布:javascript validate 编辑:程序博客网 时间:2024/05/13 13:17
You are playing the following Flip Game with your friend: Given a string that contains only these two characters: +
and -
, you and your friend take turns to flip twoconsecutive "++"
into "--"
. The game ends when a person can no longer make a move and therefore the other person will be the winner.
Write a function to determine if the starting player can guarantee a win.
For example, given s = "++++"
, return true. The starting player can guarantee a win by flipping the middle "++"
to become "+--+"
.
class Solution {public:bool firstPlayWinning(string s) {return canWin(s);}bool canWin(string& s) {for(int i=0;i<s.size()-1;i++) {if(s[i]==s[i+1]&&s[i]=='+') {s[i]=s[i+1]='-';bool win=!canWin(s);s[i]=s[i+1]='+';if(win) return true;}}return false;}};
0 0
- [LeetCode294] Flip Game II
- [LeetCode294]Flip Game II
- [leetcode294]Flip Game II
- [LeetCode294] Flip Game II
- *LeetCode-Flip Game II
- Flip Game II
- Flip Game II
- 294. Flip Game II
- LeetCode 294. Flip Game II
- Leetcode 293. Flip Game & 294. Flip Game II
- LeetCode 题解(277) :Flip Game II
- [leetcode] 294. Flip Game II 解题报告
- [Leetcode] 294. Flip Game II 解题报告
- LeetCode 294. Flip Game II(反转游戏II)
- Flip Game
- Flip Game
- Flip Game
- Flip Game
- php中将数据加入到文件中
- javascript数组去重的三种常用方法总结
- 跳转指令与协处理器指令
- AndroidStudio 布局文件出错的问题
- Android设计支持库 Design Support Library
- [LeetCode294] Flip Game II
- 使用doxygen生成注释文档——visual studio
- 键盘事件的区别
- Android项目开发实战-2048游戏
- MPLAB X IDE v2.26 导入旧的工程时遇到的一个小问题及解决方案
- ANDL使用方法
- Android Scroll分析(一)
- iOS-tableview顶部拉伸效果(头像拉伸)
- PCM data flow - part 3: ASoC codec driver