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 hints

Topics

Also asked at 3 companies


More MathWorks Questions

View all MathWorks questions