← All problemsSign in

A Game of Strings

Alice and Bob have invented a new game. Alice gives Bob a string consisting of only two types of characters i.e. $'a'$ and $'b'$. Bob can do a special operation on this string called a $flip$. If Bob flips from index $i$ to $j$ (inclusive of i and j) , all the $'a'$ in this range become $'b'$ and all the $'b'$ become $'a'$. Help Bob find the maximum number of $'a'$, in this string after

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start