#3777

Minimum Deletions to Make Alternating Substring

candidate master · 1575 · lc hard +32 · premium · 44.9% accepted · 50 likes · top 28%

Description

Given a binary string s (only 'A' and 'B') of length n and an array queries, process two operation types: [1, j] flips the character at index j in s (mutating it for future queries), and [2, l, r] reports the minimum deletions needed to make substring s[l..r] alternating (no two adjacent characters equal); return answers to all type-2 queries.

Code

1
2
3