Flip Game II Problem
Flip Game II Problem — ExecCode Hard DSA Practice
Solve the Flip Game II problem on ExecCode. Free online hard DSA practice in Backtracking. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description Problem You are given a string composed of the characters '+' and '-'. Two players alternate turns. On each turn, a player must choose two consecutive '+' characters (i.e., the substring "++") and flip them both to '-' (resulting in "--"). If a player cannot make a valid move on their turn, they lose. Assuming both players play optimally, determine whether the starting player can guarantee a win. Input Format A single line containing the string of '+' and '-' characters (no spaces). This is the entire stdin. Output Format Print "true" if the starting player can guarantee a win under optimal play, otherwise print "false". Constraints The input string length is at least 0 and contains only the characters '+' and '-'. Do not change the string during input/output beyond the described flips.
Examples
Input ++++; Output True. Input +-+-+; Output False
Constraints
1 <= n <= 10^5
Practice Flip Game II free on ExecCode. Browse DSA problems, topic map, and placement guides.