727. Convert Doubly Linked List to Array I
You are given the head of a doubly linked list, which contains nodes that have a next pointer and a previous pointer.
Return an integer array which contains the elements of the linked list in order.
Example 1:
Input: head = [1,2,3,4,3,2,1]
Output: [1,2,3,4,3,2,1]
Example 2:
Example 2:
Input: head = [2,2,2,2,2]
Output: [2,2,2,2,2]
Now Your Turn!
Pick the correct output for the given inputInput: head = [3,2,3,2,3,2]
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
The number of nodes in the given list is in the range [1, 50].
1 <= Node.val <= 50