Tap here to switch tabs
Problem
Submissions

Problem: Minimum Deletions to Make String Balanced

Try to solve the Minimum Deletions to Make String Balanced problem.

Statement

Given a string s consisting only of the characters 'a' and 'b'.

A string is considered balanced if there is no pair of indices (i, j) such that i<ji < j, s[i] is equal to 'b', and s[j] is equal to 'a'.

Return the minimum number of character deletions needed to make s balanced.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s[i] is either 'a' or 'b'

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Deletions to Make String Balanced

Try to solve the Minimum Deletions to Make String Balanced problem.

Statement

Given a string s consisting only of the characters 'a' and 'b'.

A string is considered balanced if there is no pair of indices (i, j) such that i<ji < j, s[i] is equal to 'b', and s[j] is equal to 'a'.

Return the minimum number of character deletions needed to make s balanced.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s[i] is either 'a' or 'b'