LeetCode 138: Copy List with Random Pointer — A Complete Deep-Copy Breakdown

Subtitle / Abstract The real challenge in this problem is not traversing the list, but correctly cloning the cross-node reference relationships created by random pointers. This article moves from naive intuition to a hash-mapping solution, and explains why it is stable, maintainable, and practical in real engineering. Estimated reading time: 12–16 minutes Tags: Linked List, Deep Copy, Hash Table, Random Pointer SEO keywords: LeetCode 138, Copy List with Random Pointer, random list copy, deep copy, hash mapping Meta description: Perform deep copy of a random-pointer linked list via two passes plus a mapping table, with correctness, complexity, engineering practice, and six-language implementations. Target Readers Developers who feel shaky on random pointer problems while practicing LeetCode Learners who want to clearly understand “shallow copy vs deep copy” Engineers who want to transfer algorithmic thinking to real object-copy scenarios Background / Motivation For a normal linked list, copying val and next is straightforward. A random-pointer list adds one more pointer, random, which can: ...

February 11, 2026 · 12 min · map[name:Jeanphilo]

LeetCode 1512: Number of Good Pairs (Hash Counting ACERS Guide)

Subtitle / Abstract A basic counting problem: use frequency + combinations to drop O(n^2) to O(n). Includes engineering use cases and portable implementations. Reading time: 8-10 minutes Tags: hash-table, counting, array SEO keywords: Good Pairs, hash map, frequency Meta description: Hash counting solution for Good Pairs with complexity and code. Target readers Beginners learning hash tables and counting Engineers who want to map interview patterns to real stats tasks Interview prep for basic counting models Background / Motivation Counting equal pairs is a classic problem. A double loop is O(n^2). With frequency counting, you can solve it in linear time and scale to large data. ...

December 30, 2025 · 5 min · map[name:Jeanphilo]