i am not able to think how this can be solved, need some help to proceed in this
String game problem game theory
Hint :
This game can be easily reduced to the game of nim. Each segment of consecutive same letters(for eg. “aaa”), can be considered as a pile of game of nim. For a single string, we can just take xor of the piles we defined earlier.
but what their can be new blocks formed after removing of subtring
for ex:-
bbaaabb
if we remove aaa the the block size for b will be 4
we will make two arrays suffix xor of piles ( i.e. consecutive same letters ) and prefix xor of plies and then we will see by removing any piles if we can make the xor equal to zero then B will win else A will win … Got it?
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
sir i have doubt in string game ques of game theory ,what is sufixx xor ,prefix xor of piles,how to divide string ,take xor of what??