Medium · Dynamic Programming
Minimum Deletions to Make String Balanced
Given a string s made only of 'a' and 'b', return the minimum number of characters to delete so that no 'b' comes before an 'a' in what remains.
Examples
Example 1
s = "aababbab"Output: 2 deletions
Example 2
s = "bbaaaaabb"Output: 2 deletions
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.