Problem link: Color Play
I tried a greedy approach for this problem, here is my solution :
Spoiler
But this gave me WA. So I found a test case also:
Spoiler
answer should be 1 , but my code gives 3. I guess this is DP problem. Can anyone please help.