22. Flattening a Linked List
Input:
5 -> 10 -> 19 -> 28
| | | |
7 20 22 35
| | |
8 50 40
| |
30 45
Output: 5-> 7-> 8- > 10 -> 19-> 20->
22-> 28-> 30-> 35-> 40-> 45-> 50.
Explanation :
The resultant linked lists has every
node in a single level.
(Note: | represents the bottom pointer.)Input:
5 -> 10 -> 19 -> 28
| |
7 22
| |
8 50
|
30
Output:
5->7->8->10->19->22->28->30->50
Explanation:
The resultant linked lists has every
node in a single level.
(Note: | represents the bottom pointer.)Solution:
Last updated