1
00:00:00,930 --> 00:00:03,480
Hi everyone, let's do this question.

2
00:00:03,480 --> 00:00:10,890
Given a string s, find the length of the longest substring without repeating characters.

3
00:00:10,920 --> 00:00:12,930
Now let's try to understand this question.

4
00:00:12,930 --> 00:00:17,610
Let's say the string which is given to us is x y z xp.

5
00:00:17,610 --> 00:00:19,560
So this can be a string right now.

6
00:00:19,560 --> 00:00:22,650
In this case, what are the substrings which are possible.

7
00:00:22,650 --> 00:00:27,390
We can have just x, we can just have y, we can just have Z etc..

8
00:00:27,390 --> 00:00:27,570
Right.

9
00:00:27,570 --> 00:00:30,690
So this is like a substring with length one.

10
00:00:30,690 --> 00:00:34,110
We could have x y we can have y z etc..

11
00:00:34,110 --> 00:00:36,720
So there are various substrings which are possible.

12
00:00:36,720 --> 00:00:43,410
But we can see that the longest substring without repeating characters is this one over here right y

13
00:00:43,410 --> 00:00:44,520
z xp.

14
00:00:44,580 --> 00:00:46,500
And this has a length of four.

15
00:00:46,500 --> 00:00:47,640
So this is the question.

16
00:00:47,640 --> 00:00:51,390
We need to find the longest substring without repeating characters.

17
00:00:51,390 --> 00:00:54,090
And then we have to return the length of that substring.

18
00:00:54,090 --> 00:00:56,040
So that is what is being asked to us.

19
00:00:56,040 --> 00:01:00,120
Now let's go ahead and write a few test cases for this question.

20
00:01:00,120 --> 00:01:04,740
Let's say the string which is given to us is pee pee pee pee pee.

21
00:01:04,980 --> 00:01:08,970
So in this case the longest substring over here would be just pee.

22
00:01:09,000 --> 00:01:09,360
Right?

23
00:01:09,360 --> 00:01:12,180
Because if you just take two pees, you are repeating a character.

24
00:01:12,180 --> 00:01:14,580
So in this case the length is equal to one.

25
00:01:15,060 --> 00:01:19,590
Now let's say the string which is given to us is a b c b c, c d.

26
00:01:19,710 --> 00:01:22,020
In this case the length has to be three, right?

27
00:01:22,020 --> 00:01:23,640
Which is this over here a b c.

28
00:01:23,910 --> 00:01:28,380
Now if you take this b you cannot take it right because you are repeating two B's.

29
00:01:28,380 --> 00:01:32,850
Again if you take if you start from here, you just have a substring of two characters.

30
00:01:32,850 --> 00:01:38,910
If you start from B, if you start from C, also you have a substring of two characters without repeating

31
00:01:38,910 --> 00:01:39,510
characters, right?

32
00:01:39,510 --> 00:01:45,270
So again, you can see this is the longest substring without repeating characters, and it has a length

33
00:01:45,270 --> 00:01:45,840
of three.

34
00:01:46,110 --> 00:01:49,860
Now what if the string which is given to us is this one over here?

35
00:01:50,250 --> 00:01:55,650
Now in this case, you can see that the longest substring without repeating characters is this over

36
00:01:55,650 --> 00:01:56,130
here, right.

37
00:01:56,130 --> 00:01:58,410
Starting at R and going to W.

38
00:01:58,410 --> 00:02:00,810
And this has a length of seven.

39
00:02:00,810 --> 00:02:01,350
All right.

40
00:02:01,350 --> 00:02:02,610
So this is the question.

41
00:02:02,610 --> 00:02:03,960
We have understood the question.

42
00:02:03,960 --> 00:02:09,180
Remember in the interview feel free to ask any clarifying questions you have.

43
00:02:09,180 --> 00:02:14,700
And also uh, you you can come up with test cases together with the interviewer.

44
00:02:14,700 --> 00:02:19,890
So you can say if you can ask the interviewer if he or she is ready to come up with some test cases

45
00:02:19,890 --> 00:02:20,370
together.

46
00:02:20,370 --> 00:02:26,160
So this will ensure that you have clearly understood the question, and this will prepare you to solve

47
00:02:26,160 --> 00:02:26,760
the question.

48
00:02:26,760 --> 00:02:31,740
Now, in the next video, let's try to think how we can solve this question.
