1
00:00:00,830 --> 00:00:03,590
Hi everyone, let's do this question.

2
00:00:03,590 --> 00:00:08,060
You are given the head of a sorted singly linked list.

3
00:00:08,060 --> 00:00:11,360
Write a function that will take the given head as input.

4
00:00:11,360 --> 00:00:17,180
Delete all nodes that have a value that is already the value of another node, so that each value appears

5
00:00:17,180 --> 00:00:21,770
one time only and return the linked list which is still to be sorted.

6
00:00:21,770 --> 00:00:22,880
A sorted linked list.

7
00:00:22,880 --> 00:00:26,210
All right, so we are given a linked list, a singly linked list.

8
00:00:26,210 --> 00:00:30,290
And we need to delete all the duplicate values and return it.

9
00:00:30,290 --> 00:00:31,400
So that's the question.

10
00:00:31,400 --> 00:00:37,130
Now if you get this question in the interview feel free to ask any clarifying questions you may have.

11
00:00:37,130 --> 00:00:42,950
Now let's proceed and write some test cases to understand what the question asks us.

12
00:00:42,950 --> 00:00:44,420
And what's the expectation.

13
00:00:44,420 --> 00:00:48,380
Let's say the singly linked list which is given to us is this one.

14
00:00:48,800 --> 00:00:52,820
So we have a node with value one which is pointing to a node with value two.

15
00:00:52,850 --> 00:00:57,440
Again, that's pointing to another node with value two, and so on and so forth.

16
00:00:57,440 --> 00:00:59,930
So we can see that this is repeating right.

17
00:00:59,930 --> 00:01:03,440
And again over here we have the same value occurring three times.

18
00:01:03,440 --> 00:01:09,500
So if this is the input the output would be one pointing to two pointing to three pointing to four.

19
00:01:09,500 --> 00:01:10,700
And that points to null.

20
00:01:10,700 --> 00:01:12,380
So there is no repeating value.

21
00:01:12,380 --> 00:01:15,110
So that's what we need to achieve in this question.

22
00:01:15,110 --> 00:01:18,170
Now do give it a thought on how you could solve it.

23
00:01:18,170 --> 00:01:22,970
Now again remember the interesting thing over here is that the singly linked list is sorted.

24
00:01:22,970 --> 00:01:25,010
So that's mentioned in the question.

25
00:01:25,010 --> 00:01:29,780
So think about how you can make use of this also while you solve this question.
