
loveA
Alice has a string s
. She really likes the letter "a"
. She calls a string good if strictly more than half of the characters in that string are "a"
. For example "aaabb"
, "axaa"
are good strings, and "baca"
, "awwwa"
, ""
(empty string) are not.
Alice can erase some characters from her string . She would like to know what is the longest string remaining after erasing some characters (possibly zero) to get a good string. It is guaranteed that the string has at least one "a"
in it, so the answer always exists.
Example
- For
s = "aaabb"
the output should beloveA(s) = 5
Input/Output
-
[execution time limit] 0.5 seconds
- [Input] string s
Guaranteed constraints:
1 <= |s| <= 50
- [Output]
The length of the longest good string that Alice can get after erasing some characters from .
Post Comment