Leetcode 293. Flip Game (Easy) (cpp)
来源:互联网 发布:vb的注释符号 编辑:程序博客网 时间:2024/05/17 04:29
Leetcode 293. Flip Game (Easy) (cpp)
Tag: String
Difficulty: Easy
/*293. Flip Game (Easy)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 two consecutive "++" 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 compute all possible states of the string after one valid move.For example, given s = "++++", after one move, it may become one of the following states:["--++","+--+","++--"]If there is no valid move, return an empty list [].*/class Solution {public:vector<string> generatePossibleNextMoves(string s) {if (s.empty()) {return{};}vector<string> res;for (int i = 0; i < s.size() - 1; i++) {if (s[i] == '+' && s[i + 1] == '+') {s[i] = '-';s[i + 1] = '-';res.push_back(s);s[i] = '+';s[i + 1] = '+';}}return res;}};
0 0
- Leetcode 293. Flip Game (Easy) (cpp)
- LeetCode 293. Flip Game
- Leetcode 292. Nim Game (Easy) (cpp)
- Leetcode Everyday: 293. Flip Game
- Leetcode 293. Flip Game & 294. Flip Game II
- [leetcode] 293. Flip Game 解题报告
- LeetCode 293. Flip Game(反转游戏)
- [Leetcode] 293. Flip Game 解题报告
- [LeetCode 293] Flip Game
- *LeetCode-Flip Game II
- [leetcode 293] Flip Game
- Leetcode 293: Flip Game
- Leetcode: Flip Game
- [LeetCode 293] Flip Game
- LeetCode 题解(276) :Flip Game
- Leetcode NO.293 Flip Game
- 【Leetcode】 Flip Game 翻转游戏
- LeetCode 294. Flip Game II
- 基于 Swift 创建 CocoaPods 完全指南
- e820 -- retrieve memory map from BIOS
- 【51Nod 1189】阶乘分数
- 2016最新CocoaPods安装和错误解决
- AndroidStudio汉化包安装及使用方法
- Leetcode 293. Flip Game (Easy) (cpp)
- 更加精确的TCP Westwood拥塞控制算法
- 一起talk C栗子吧(第一百九十二回:C语言实例--DIY less命令一 )
- 英语学习(一)
- 菜鸟学习笔记:java中使用Integer.getInteger(String)有java.lang.NullPointerException
- last命令--Linux命令应用大词典729个命令解读
- man命令--Linux命令应用大词典729个命令解读
- init命令--Linux命令应用大词典729个命令解读
- mv命令--Linux命令应用大词典729个命令解读