Backend Engineering
Mid-Level
programming
LeetCode #293 - Flip Game
Given a string that contains only these two characters: "+" and "-", you need to reverse the signs of the string's segments. A segment is defined as consecutive characters of the same type. You need to generate all possible states after flipping the signs of segments. When you flip a segment, you change the '+'s to '-'s and vice versa. Return the list of all possible states in any order.Input:
"++--"Output:
[
"++++",
"+--+",
"-++-",
"-+--",
"--++",
"----"
]Constraints:
"++--"Output:
[
"++++",
"+--+",
"-++-",
"-+--",
"--++",
"----"
]Constraints:
- The input string will only contain characters '+' and '-'.
- The length of the string will be in the range [1, 20].
Suggested Answer