Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Start from each 'a' and find the longest beautiful substring starting at that index.
Based on the current character decide if you should include the next character in the beautiful substring.