Merge Two Sorted Lists
Read the lesson → understand the pattern → then code. Tutor works offline (built-in teacher); optional Cursor/Gemini keys upgrade chat quality.
Topic refresher: Linked List — Pointer Surgery
Redraw next pointers carefully; draw on paper first.
ListNode* prev = nullptr;
ListNode* cur = head;
while (cur) {
ListNode* nxt = cur->next;
cur->next = prev;
prev = cur;
cur = nxt;
}
return prev;EasyLinked ListLeetCode #21
Merge Two Sorted Lists
Dummy head + stitch smaller node each time.
Examples
Example 1
Input
3 1 2 4 3 1 3 4
Output
1 1 2 3 4 4
Example 2
Input
0 0
Output
Stuck? Take a nudge
C++17Autosaves