The Flip Game interview question is a string simulation based on a simple game rule. You are given a string containing only '+' and '-' characters. Two players take turns flipping two consecutive "++" into "--". Your goal is to return a list of all possible strings that can result from a single valid move.
Google asks the Flip Game coding problem to assess basic string manipulation and loop control. It tests whether you can accurately identify patterns (consecutive pluses) and create new strings based on those patterns. It evaluations your proficiency in String interview patterns and your ability to handle immutable data types correctly.
This problem follows the Linear Scan and Replacement pattern.
s[i] == '+' and s[i+1] == '+'.String: "++++"
["--++", "+--+", "++--"].s[i+1] out of bounds.Practice creating substrings and concatenating them. In most languages, the most efficient way to flip characters at i and i+1 is s.substring(0, i) + "--" + s.substring(i+2). This is a vital String interview pattern skill.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Count Asterisks | Easy | Solve | |
| Generate a String With Characters That Have Odd Counts | Easy | Solve | |
| Goal Parser Interpretation | Easy | Solve | |
| License Key Formatting | Easy | Solve | |
| Occurrences After Bigram | Easy | Solve |