For this Question: Given a sorted doubly linked list containing n nodes. Your task is to remove duplicate nodes from the given list.

Example 1:
Input
1<->2<->2-<->3<->3<->4

Output:
1<->2<->3<->4

Example 2:
Input
1<->1<->1<->1

Output
1<b>User Task:</b>
Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>deleteDuplicates()</b> that takes head node as parameter.

Constraints:
1 <=N <= 10000
1 <= Node. data<= 2*10000Return the head of the modified list.Sample Input:-
6
1 2 2 3 3 4

Sample Output:-
1 2 3 4

Sample Input:-
4
1 1 1 1

Sample Output:-
1, I have written this Solution Code:     public static Node deleteDuplicates(Node head)  
    {  
        /* if list is empty */
        if (head== null)  
            return head;  
    
        Node current = head;  
        while (current.next != null)  
        {  
            /* Compare current node with next node */
            if (current.val == current.next.val)  
                /* delete the node pointed to by  
              ' current->next' */
                deleteNode(head, current.next);  
    
            /* else simply move to the next node */
            else
                current = current.next;  
        }   
    
      
        return head;
    }  
  
  
    /* Function to delete a node in a Doubly Linked List.  
    head_ref --> pointer to head node pointer.  
    del  -->  pointer to node to be deleted. */
    public static void deleteNode(Node head, Node del) 
    { 
         /* base case */
        if(head==null || del==null) 
        { 
            return ; 
        } 
        /* If node to be deleted is head node */
        if(head==del) 
        { 
            head=del.next; 
        } 
        /* Change next only if node to be deleted   
        is NOT the last node */
        if(del.next!=null) 
        { 
            del.next.prev=del.prev; 
        } 
        /* Change prev only if node to be deleted   
       is NOT the first node */
        if (del.prev != null)  
            del.prev.next = del.next;  
  
    }, In this Programming Language: Java, Now tell me if this Code is compilable or not?