00:01
So, hello everyone.
00:03
Today we will be solving a problem that involves manipulating a string into some other format.
00:31
The code on the screen is in python.
00:37
So, let's get started.
00:39
We are given a string s which is consisting only of letters a and or b.
00:53
Our goal is to obtain a string in the format a, ab and b.
01:05
This is our outcome where all the letters a occur before all the letters b.
01:15
We need to find the minimum number of letters that need to be deleted from s to achieve this format.
01:52
So, we define the solution s.
01:55
We will use two variables that is counta and countb, both of which are initialized to 0.
02:07
This keeps a track of capital a and this keeps a track of capital b that would be encountered in the string.
02:17
We will also have two variables that is deletea and deleteb.
02:23
To keep the track of minimum number of deletions required, we will iterate through each letter in the string s and check if it is a or b.
02:56
If it is a, then we increment the count by 1 and add the current count of b letters to delete b.
03:07
Since we need to delete those b letters to maintain the desired format.
03:22
Similarly, if it is b, if the element found is b, we increase the countb, count underscore b to 1 and add the current count of a to delete a...