• + 1 comment

    Simple Java iterative java solution

    Node Reverse(Node head) {
        if(head == null)
            return null;
        if(head.next == null)
            return head;
        Node temp = null; 
        Node current = head;
        while(current != null){
    
            temp = current.prev;
            current.prev = current.next; 
            current.next = temp; 
            current = current.prev;
            
        }
        if(temp!=null)
            head = temp.prev;
        return head;
        
    }