Given the head of a doubly linked list and an integer val, insert a new node with value val at the end. Update prev and next pointers. Return the head.
Traverse to the last node, attach new node, and update prev pointer.
Input: Head of a doubly linked list and integer val.
Output: Head of the updated doubly linked list.
Input: [1,2,3], 4
Output: [1,2,3,4]
Explanation: Traverse to node(3). newNode(4).prev=3; 3.next=newNode(4). Return head(1).Input: [], 5
Output: [5]
Explanation: Empty list. New node is head.Input: [7], 8
Output: [7,8]
Explanation: One node. 7.next=8; 8.prev=7. Return 7.0<=nodes<=10^5-10^9<=Node.val<=10^9