dsa2 min read
Flatten Multilevel Doubly Linked List — DFS Stack
Flatten a multilevel doubly linked list by inserting child sub-lists inline using DFS or an explicit stack.
Read →
webcoderspeed.com
1276 articles
Flatten a multilevel doubly linked list by inserting child sub-lists inline using DFS or an explicit stack.
Find the node where a cycle begins using Floyd's algorithm: detect meeting point, then reset one pointer to head.
Find the duplicate in an array of n+1 integers in O(1) space by treating indices as a linked list with Floyd's cycle detection.
Find the next greater value for each node in a linked list using a monotonic decreasing stack of indices.
Implement a doubly linked list with sentinel head and tail nodes for clean O(1) insertions and deletions.