Question: We are given a string S of length N , consisting only of letters ' A ' and / or ' B ' . Our
We are given a string S of length N consisting only of letters A andor B Our goal is to obtain a string
in a format AABBall letters A occur before all letters B by deleting some letters from S
In particular, strings consisting only of letters A or only of letters B fit this format
Write a function
int solutionString S
that given a string S return the minimum number of letters that need to be deleted from S in order to obtain a
string in the above format.
Example
Given S "BAAABAB", the function should return We can obtain "AAABB" by deleting the occurrence of B and
the last occurrance of A
Given S "BBABAA", the function should return we can delete all occurrence of A or all occurrence of B
Given S "AABBBB", the function should return
we do not have to delete any letters because the given string is already in the format.
Write code in java
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
