linked_list.md

June 20, 2026 ยท View on GitHub

๐Ÿš€ Practice & deep-dive on EmbeddedInterviewLab

Solve these in-browser with a C/C++ editor and AI-graded evaluation, and browse the ranked question bank.

๐Ÿ‘‰ Practice coding problems with AI feedback โ†’ ย ยทย  Open the Interview Question Bank โ†’


Problems

Index #TitleDiffcultyImportance/Frequency
1Reverse Linked ListEasy*****
2Reverse Linked List IIMedium***
3Linked List CycleEasy*****
4Palindrome Linked ListEasy****
5Remove Linked List ElementsEasy****
6Delete Node in a Linked ListEasy*****
7Remove Duplicates from Sorted ListEasy*****
8Merge Two Sorted ListsEasy*****
9Flatten Binary Tree to Linked ListMedium**
10Intersection of Two Linked ListsEasy****
11LRU cacheHard****
12Middle of linked listEasy****
13Implement queue by linked listEasy****
14Reorder ListMedium****

Implementation

Reorder List

Big O: O(n) speed, O(1) space

Tips: 

1. Find a Middle Node.
2. Reverse the Second Part of the List.
3. Merge Two Sorted Lists.
class Solution {
public:
	void reorderList(ListNode* head) {
		if ( ! head ) return;
		ListNode *slow = head, *fast = head;
		while ( fast->next && fast->next->next )
		{
			slow = slow->next;
			fast = fast->next->next;
		}
			
		
		ListNode *prev = NULL, *cur = slow->next, *save;
		while ( cur )
		{
			save = cur->next;
			cur->next = prev;
			prev = cur;
			cur = save;
		}
			
		slow->next = NULL;
		
		ListNode *head2 = prev;
		while ( head2 )
		{
			save = head->next;
			head->next = head2;
			head = head2;
			head2 = save;
		}      
	}
};