342. Remove Duplicates from Sorted List

0

Easy

Given the head of a sorted linked list, remove all duplicate elements so that each element appears only once. Return the updated linked list, which should also be sorted.

Input Format

An integer n representing the number of nodes in the linked list.

Followed by n integers representing the values of the nodes in the linked list.

Followed by n integers representing the values of the nodes in the linked list.

Output Format

Print the updated linked list.

Example

Input

4
1 1 2 2

Output

1 2

Constraints

The number of nodes in the linked list ranges from 0 to 300.

Each node's value is between -100 and 100.

The linked list is guaranteed to be sorted in ascending order.

Each node's value is between -100 and 100.

The linked list is guaranteed to be sorted in ascending order.

Loading...

View Submissions

Console