Practice Minimum Deletions to Make String Balanced
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a string s consisting only of characters 'a' and 'b'. You can delete any number of characters in s to make s balanced. s is balanced if there is no pair of indices (i,j) such that i < j and s[i] = 'b' and s[j]= 'a'. Return the minimum number of deletions needed to make s balanced.
Source: Minimum Deletions to Make String Balanced on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "aababbab"
2
# Example 2
s = "bbaaaaabb"
2
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Deletions to Make String Balanced.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.