Remove Colored Pieces if Both Neighbors are the Same Color at MathWorks
Medium63.0% acceptance
This problem has 87.5% frequency at MathWorks.
Problem Description
There are `n` pieces arranged in a line, and each piece is colored either by `'A'` or by `'B'`. You are given a string `colors` of length `n` where `colors[i]` is the color of the `ith` piece. Alice and Bob are playing a game where they take **alternating turns** removing pieces from the line. In t...
Read full problem and hintsTopics
Also asked at 3 companies
More MathWorks Questions
Maximum Palindromes After OperationsMediumSell Diminishing-Valued Colored BallsMediumCount AnagramsHardLast Substring in Lexicographical OrderHardMinimum Cost Tree From Leaf ValuesMedium
View all MathWorks questions