Question: Please solve in typescript Write a function solution that, given a string S consisting of N letters ' a ' and / or ' b
Please solve in typescript
Write a function solution that, given a string consisting of letters a andor b returns true when all occurrences of letter a are before all occurrences of letter b and returns false otherwise.
Examples:
Given "aabbb", the function should return true.
Given ba the function should return false.
Given "aaa", the function should return true. Note that b does not need to occur in S
Given b the function should return true. Note that a does not need to occur in S
Given "abba", the function should return false.
Write an efficient algorithm for the following assumptions:
N is an integer within the range ;
string is made only of the characters a andor b
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
