Hi everyone, let's do this question.
Given a string s, find the length of the longest substring without repeating characters.
Now let's try to understand this question.
Let's say the string which is given to us is x y z xp.
So this can be a string right now.
In this case, what are the substrings which are possible.
We can have just x, we can just have y, we can just have Z etc..
Right.
So this is like a substring with length one.
We could have x y we can have y z etc..
So there are various substrings which are possible.
But we can see that the longest substring without repeating characters is this one over here right y
z xp.
And this has a length of four.
So this is the question.
We need to find the longest substring without repeating characters.
And then we have to return the length of that substring.
So that is what is being asked to us.
Now let's go ahead and write a few test cases for this question.
Let's say the string which is given to us is pee pee pee pee pee.
So in this case the longest substring over here would be just pee.
Right?
Because if you just take two pees, you are repeating a character.
So in this case the length is equal to one.
Now let's say the string which is given to us is a b c b c, c d.
In this case the length has to be three, right?
Which is this over here a b c.
Now if you take this b you cannot take it right because you are repeating two B's.
Again if you take if you start from here, you just have a substring of two characters.
If you start from B, if you start from C, also you have a substring of two characters without repeating
characters, right?
So again, you can see this is the longest substring without repeating characters, and it has a length
of three.
Now what if the string which is given to us is this one over here?
Now in this case, you can see that the longest substring without repeating characters is this over
here, right.
Starting at R and going to W.
And this has a length of seven.
All right.
So this is the question.
We have understood the question.
Remember in the interview feel free to ask any clarifying questions you have.
And also uh, you you can come up with test cases together with the interviewer.
So you can say if you can ask the interviewer if he or she is ready to come up with some test cases
together.
So this will ensure that you have clearly understood the question, and this will prepare you to solve
the question.
Now, in the next video, let's try to think how we can solve this question.