You are given a linked list where each node contains two pointers:
next pointer: Points to the next node in the main linked list.
bottom pointer: Points to the head of another sorted sub-linked list.
Each sub-linked list is sorted in ascending order. Flatten the Link List so all the nodes appear in a single level while maintaining the sorted order.
Note: The flattened linked list should be printed using the bottom pointer instead of the next pointer. Refer to the printList() function in the driver code for better understanding.
Topics
Companies
Articles
Examples:
Expected Time Complexity: O(n*n*m)
Expected Space Complexity: O(n)
Constraints:
0 <= number of nodes <= 50
1 <= no. of nodes in sub-LinkesList(mi) <= 20
1 <= node->data <= 10^3
Companies:
AmazonMicrosoftVisaGoldman SachsFlipkart + 1 more
Topics:
Linked List
Please log in to access the Submissions tab, where you can review your progress and explore code submissions from other participants.
Please log in to access the Solution tab and view detailed answers and explanations.
Please log in to access the Discussion tab and join conversations with other participants.
Access Restricted: Please Login to access the code editor and test cases.