'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

A doubly-linked list is a data structure that consists of sequentially linked nodes, and the nodes have reference to both the previous and the next nodes in the sequence of nodes.

You are given a sorted doubly linked list of size * 'n'*, consisting of distinct positive integers, and a number

Find out all the pairs in the doubly linked list with sum equal to 'k'.

```
Input: Linked List: 1 <-> 2 <-> 3 <-> 4 <-> 9 and 'k' = 5
Output: (1, 4) and (2, 3)
Explanation: There are 2 pairs in the linked list having sum 'k' = 5.
```

Detailed explanation

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

```
2
1 4
2 3
```

```
There are 2 pairs in the linked list having sum equal to 'k' (= 5).
```

```
5
1 10 11 12 27
7
```

```
0
```

```
There is no pair in the linked list with sum equal to 'k' (= 7).
```

```
The expected time complexity is O('n').
```

```
2 <= 'n' <= 10 ^ 4
1 <= 'data' in any node <= 10 ^ 4
1 <= 'k' <= 10 ^ 4
'data' in every node is distinct.
Time limit: 1 second
```