Odd Even Linked List | Two Chains, One Pass | LeetCode 75 #30
Placements
0:00 / 0:00
Odd Even Linked List | Two Chains, One Pass | LeetCode 75 #30
3 просмотра · 13 дней назад
Placements
2 подписчика
3 просмотра · 13 дней назад
Odd Even Linked List (LeetCode 328, Medium) — explained in Hindi, from absolute zero.
Group all odd-index nodes first, then even-index nodes — in one pass, O(1) space, by rewiring arrows in place. The card-deal intuition: two players (odd and even pointers), every node dealt to exactly one chain, no node ever dropped. Full animated dry run on [2,1,3,5,6,4,7], line-by-line C++ walkthrough (why every line exists), and three hard parts opened slowly: (1) why a skipped node is never lost — the held-by-the-other-chain invariant, (2) the final join via evenHead plus the cycle trap if the even tail is not null, (3) why the loop needs BOTH even and even→next checks — one check crashes on each parity. Correctness proof via loop invariant, O(n) time / O(1) space reasoning, 8 edge cases, and interview Q&A.
Problem: https://leetcode.com/problems/odd-eve...
Timestamps:
00:00 Intro — Two Chains, One Pass
01:17 Problem — Odd Positions vs Even Values
04:21 Brute Force — Copy Nodes (and why it fails)
06:04 The Idea — Card Dealing
09:07 Hard Part 1 — Skipped Node Never Lost
13:24 Hard Part 2 — Final Join and Cycle Trap
16:59 Hard Part 3 — Loop Condition (Both Checks)
19:56 Full Dry Run — [2,1,3,5,6,4,7]
24:06 C++ Code — Line by Line (Why)
28:18 Edge Cases — 8 Tests
30:21 Correctness Proof — Loop Invariant
32:23 Interview Q&A
33:42 Outro — Recap
#LeetCode #DSAinHindi #CodingInterview #Placements #Cpp #LeetCode75 #LinkedList #OddEvenLinkedList