@@ -0,0 +1,2563 @@
+package study.hard.javalib.hackerrank;%0A%0Aimport java.util.Scanner;%0Aimport java.util.Set;%0Aimport java.util.HashSet;%0A%0A/**%0A * Created by iandmyhand on 10/16/16.%0A */%0A%0Aclass Node %7B%0A    int data;%0A    Node next;%0A    Node(int data)%7B%0A        this.data = data;%0A        this.next = null;%0A    %7D%0A%7D%0Apublic class SolutionLinkedListDeletion %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        Scanner scan = new Scanner(System.in);%0A        Node head = null;%0A        int T = scan.nextInt();%0A        while(T--%3E0) %7B%0A            head = insert(head, scan.nextInt());%0A        %7D%0A        head = removeDuplicates(head);%0A        display(head);%0A    %7D%0A%0A    static Node insert(Node head, int data) %7B%0A        if(null == head) return new Node(data);%0A        else %7B%0A            Node cur = head;%0A            while(true) %7B%0A                if(null == cur.next) %7B%0A                    cur.next = new Node(data);%0A                    return head;%0A                %7D%0A                cur = cur.next;%0A            %7D%0A        %7D%0A    %7D%0A%0A    static Node removeDuplicates(Node head) %7B%0A        Set%3CInteger%3E set = new HashSet();%0A        Node cur = head;%0A        while(null != cur) %7B%0A            set.add(cur.data);%0A            cur = cur.next;%0A        %7D%0A        Integer%5B%5D sorted = set.toArray(new Integer%5B0%5D);%0A        quickSort(sorted, 0, sorted.length - 1);%0A        return toLinkedList(sorted);%0A    %7D%0A%0A    private static void quickSort(Integer%5B%5D arr, Integer l, Integer r) %7B%0A        Integer i = partition(arr, l, r);%0A        if(l %3C i - 1) quickSort(arr, l, i - 1);%0A        if(r %3E i) quickSort(arr, i, r);%0A    %7D%0A%0A    private static Integer partition(Integer%5B%5D arr, int l, int r) %7B%0A        Integer i = l, j = r;%0A        Integer pivot = arr%5B(l + r) / 2%5D;%0A        while(i %3C= j) %7B%0A            while(pivot %3E arr%5Bi%5D) i++;%0A            while(pivot %3C arr%5Bj%5D) j--;%0A            if(i %3C= j) %7B%0A                swap(arr, i, j);%0A                i++;%0A                j--;%0A            %7D%0A        %7D%0A        return i;%0A    %7D%0A%0A    private static void swap(Integer%5B%5D array, int l, int r) %7B%0A        int t = array%5Bl%5D;%0A        array%5Bl%5D = array%5Br%5D;%0A        array%5Br%5D = t;%0A    %7D%0A%0A    private static Node toLinkedList(Integer%5B%5D arr) %7B%0A        Node head = new Node(arr%5B0%5D);%0A        Node cur = head;%0A        for(int i = 1; i %3C arr.length; i++) %7B%0A            cur.next = new Node(arr%5Bi%5D);%0A            cur = cur.next;%0A        %7D%0A        return head;%0A    %7D%0A%0A    static void display(Node cur) %7B%0A        if(null == cur) return;%0A        else %7B%0A            System.out.print(String.format(%22%25d %22, cur.data));%0A            display(cur.next);%0A        %7D%0A    %7D%0A%7D%0A

Solve a problem that deletion of LinkedList.