'Coding has over 700 languages', '67% of programming jobs aren’t in the
technology industry', 'Coding is behind almost everything that is powered
by electricity'

Topics

You are given an array ** ‘Arr’** of size

Your task is to make a doubly linked list from the array and return the head of the linked list.

Here, the head of the doubly linked list is the first element of the array, and the tail of the doubly linked list is the last element.

```
A doubly linked list is one in which it is possible to access the next and the previous nodes from a node in the linked list (if they exist).
```

```
Input: ‘N’ = 4, ‘Arr’ = [4, 2, 5, 1]
Output: 4 2 5 1
Explanation: Doubly Linked List for the array ‘Arr’ = [4, 2, 5, 1] is 4 <-> 2 <-> 5 <-> 1.
```

Detailed explanation

```
4
4 2 5 1
```

```
4 2 5 1
```

```
Input: ‘N’ = 4, ‘Arr’ = [4, 2, 5, 1]
Output: 4 2 5 1
Explanation:
Doubly Linked List for the array ‘Arr’ = [4, 2, 5, 1] is 4 <-> 2 <-> 5 <-> 1.
```

```
5
4 3 2 1 5
```

```
4 3 2 1 5
```

```
Input: ‘N’ = 5, ‘Arr’ = [4, 3, 2, 1, 5]
Output: 4 3 2 1 5
Explanation:
Doubly Linked List for the array ‘Arr’ = [4, 3, 2, 1, 5] is 4 <-> 3 <-> 2 <-> 1 <-> 5.
```

```
Try solving this in O(N).
```

```
1 <= 'N' <= 10^4
1 <= 'Arr[i]' <= 10^5
Time Limit: 1 sec
```