00:01
Hello students, here the string s is given to us and in this string we have to calculate to find furthest diagrams.
00:11
Now here what is diagram? a sequence of two adjacent letters inside a string is called a diagram.
00:18
And here suppose i have taken this string a b c d e.
00:22
So here i have to find the diagrams.
00:25
Here b c and d e, there are the two diagrams and now the distance between these two diagrams is the distance between the first letter of the first diagram and the first letter of the second diagram.
00:37
Here the first diagram is b a and the second diagram is d a.
00:42
So the difference between these two is one letter gap that is c.
00:48
So here i write one for this b to d and here from c to e the distance is also taken one.
00:55
That's why one plus one.
00:57
This is the two.
00:58
This is the length of the diagram.
01:02
And here i have to calculate the maximum distance which is two in the given example which i have taken a b c d e for the string.
01:15
Now here function is find furthest distance and here as we are sending the string will be given to us.
01:23
The string in this string we have to find the diagram.
01:27
So here to find the diagram here for loop is written.
01:31
So here s will work as a split.
01:35
Here we have to split the s into two diagrams so that we can find the distance.
01:41
So here i such that i plus two means first i and if this is i then this will be i plus two.
01:53
So in this way it will work.
01:55
And here at the starting maximum distance is taken as minus one.
02:00
Initialize the maximum distance minus one.
02:03
Because no identical diagram found yet.
02:05
There is no diagram.
02:07
If there is a distance then it means we have find the diagram.
02:10
Now i have taken the two for loop.
02:13
One is loop variable i and in the second the loop variable is j.
02:17
I is working up to the length of diagram and j is working up to the length of diagrams.
02:24
Here i and after this j and j will be work after i plus one.
02:32
So i and j will work in this way.
02:37
If diagrams of i for i and diagrams for j if these are equal these are identical then we will find the distance j minus i.
02:48
Calculate the distance between two and that will be the maximum distance.
02:53
We have two distances.
02:56
One is maximum distance and the second one is the distance...