Sale
Summer Offer: $190/yr $99/yr
00 : 00 : 00 : 00
Get this deal
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:
  • The input string will only contain characters '+' and '-'.

  • The length of the string will be in the range [1, 20].
Suggested Answer

Trusted by 100+ professionals preparing for interviews

Trusted by 100+ professionals 50+ Company Question Banks 5+ Supported Languages

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.

Get Started Free

More Backend Engineering Interview Prep

Can you describe a time when you had to design a backend system to handle a significant scale or load? What architecture did you decide on, and why?
Backend Engineering · Mid-Level
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Link copied to clipboard