Ctrl K

Two Pluses Into Minuses

Easy
In a board game, a position is written as a string board of '+' and '-' characters. In one move a player picks two adjacent pluses "++" and turns them into "--". Return every position reachable from board in exactly one move, in any order. If no move is possible, return an empty list.
Example 1
board="+++-" → ['--+-', '+---']

Adjacent pluses sit at positions 0–1 and 1–2, so there are two moves.

Example 2
board="-+-+" → []

No two pluses are adjacent, so there is no move.

Example 3
board="++-++" → ['---++', '++---']
Constraints
  • 1 ≤ len(board) ≤ 500
  • every character of board is '+' or '-'
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
board="+++-"
Expected
['--+-', '+---']

Run checks the first 3 tests in your browser. Submit checks all 132 tests on the server, hidden ones included.