Watch 10 video solutions for Convert Doubly Linked List to Array I, a easy level problem involving Array, Linked List, Doubly-Linked List. This walkthrough by Greg Hogg has 225,901 views views. Want to try solving it yourself? Practice on FleetCode or read the detailed text solution.
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:
Input: head = [2,2,2,2,2]
Output: [2,2,2,2,2]
Example 3:
Input: head = [3,2,3,2,3,2]
Output: [3,2,3,2,3,2]
Constraints:
[1, 50].1 <= Node.val <= 50