Associated Course(s):
Interview Preparation

Given a linked list of **N** nodes. The task is to remove duplicates from the given list (if exists).

For example if the linked list is **11->11->11**->21->**43->43**->60, then linked list should be converted to 11->21->43->60.

**Note:** Try not to use extra space. Expected time complexity is O(N).

**Input:**

First line of input contains number of testcases T. For each testcase, first line of input contains length of linked list and next line contains the linked list data.

**Output:**

For each testcase, there will be a single line of output which contains linked list with no duplicates.

**User Task:**

The task is to complete the function **removeDuplicates**() which should remove the duplicates from linked list.

**Constraints:**

1 <= T <= 100

1 <= N <= 100

**Example:**

**Input**

2

4

2 2 4 5

5

2 2 2 2 2

**Output**

2 4 5

2

**Explanation:
Testcase 1:** In the given linked list 2 ->2 -> 4-> 5, only 2 occurs more than 1 time.

Author: Shubham Joshi 1

mohamadhegazy97 | 57 |

ManojBharadhwaj | 49 |

bhatabhi554 | 48 |

adityak12 | 48 |

RaghavJindal | 47 |

blackshadows | 940 |

SunkyuHwang | 794 |

bently_nixon | 701 |

mb1973 | 491 |

Shaurya Khanna | 491 |

akhayrutdinov | 5043 |

Ibrahim Nash | 4967 |

blackshadows | 4640 |

Quandray | 4354 |

sanjay05 | 3668 |

Login to report an issue on this page.