Given a matrix. Convert it into a linked list matrix such that each node is connected to its next right and down node.
Input : 2D matrix 1 2 3 4 5 6 7 8 9 Output : 1 -> 2 -> 3 -> NULL | | | v v v 4 -> 5 -> 6 -> NULL | | | v v v 7 -> 8 -> 9 -> NULL | | | v v v NULL NULL NULL
Question Source : Factset Interview Experience | Set 9
The idea is to construct a new node for every element of matrix and recursively create its down and right nodes.
1 2 3 4 5 6 7 8 9
This article is contributed by Mandeep Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Construct a linked list from 2D matrix (Iterative Approach)
- Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes
- Circular Matrix (Construct a matrix with numbers 1 to m*n in spiral way)
- Create new linked list from two given linked list with greater element at each node
- Construct tree from ancestor matrix
- Construct a unique matrix n x n for an input n
- Difference between Singly linked list and Doubly linked list
- Convert singly linked list into circular linked list
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 2
- XOR Linked List - A Memory Efficient Doubly Linked List | Set 1
- Merge a linked list into another linked list at alternate positions
- Construct Ancestor Matrix from a Given Binary Tree
- Convert Singly Linked List to XOR Linked List
- Check if a linked list is Circular Linked List
- Create a linked list from two linked lists by choosing max element at each position
Improved By : princiraj1992