Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 30 q3: Minimum deletion to make string balanced #624

Open
Smita-Maurya opened this issue Jan 28, 2024 · 2 comments
Open

Day 30 q3: Minimum deletion to make string balanced #624

Smita-Maurya opened this issue Jan 28, 2024 · 2 comments

Comments

@Smita-Maurya
Copy link
Contributor

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.

Example 1:
Input: s = "aababbab"
Output: 2
Explanation: You can either:
Delete the characters at 0-indexed positions 2 and 6 ("aababbab" -> "aaabbb"), or
Delete the characters at 0-indexed positions 3 and 6 ("aababbab" -> "aabbbb").

@Tech-neophyte
Copy link
Contributor

Hey! Please assign this ques to me @bh-g

@Kalpana8055
Copy link
Contributor

@bh-g please assign to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants