Write code to remove duplicates from an unsorted linked list.

Example1:


 Input: [1, 2, 3, 3, 2, 1]

 Output: [1, 2, 3]

Example2:


 Input: [1, 1, 1, 1, 2]

 Output: [1, 2]

Note:

  1. The length of the list is within the range[0, 20000].
  2. The values of the list elements are within the range [0, 20000].

Follow Up:

How would you solve this problem if a temporary buffer is not allowed?