3777. Minimum Deletions to Make Alternating Substring
You are given a string
sof lengthnconsisting only of the characters'A'and'B'.You are also given a 2D integer array
queriesof lengthq, where eachqueries[i]is one of the following:
[1, j]: Flip the character at indexjofsi.e.'A'changes to'B'(and vice versa). This operation mutatessand affects subsequent queries.[2, l, r]: Compute the minimum number of character deletions required to make the substrings[l..r]alternating. This operation does not modifys; the length ofsremainsn.A substring is alternating if no two adjacent characters are equal. A substring of length 1 is always alternating.
Return an integer array
answer, whereanswer[i]is the result of thei^thquery of type[2, l, r].
1 |
|