JZLeetCode
RSS FeedHigh quality leet code solutions in Java, Python, C++, and Rust.
Comment in the Disqus section at the bottom of every post (you may have to refresh) if you have any questions. You can also share the solution on social media with the buttons at the bottom left of each post.
Please add a note that your reference or source is @JZLeetCode.
Social links for BuyMeCoffee is below and at the bottom right of every post. Donations are greatly appreciated and welcomed.
Read the blog posts or check About for more info.
Featured
-
LeetCode 5 Longest Palindromic Substring
Solutions for LeetCode 5, medium, tags: string, dynamic programming.
-
LeetCode 2462 Total Cost to Hire K Workers
Solutions for LeetCode 2462, medium, tags: array, two pointers, heap (priority queue), simulation.
-
LeetCode 48 Rotate Image
Solutions for LeetCode 48, medium, tags: array, math, matrix.
-
LeetCode 994 Rotting Oranges
Solutions for LeetCode 994, medium, tags: array, breadth-first search, matrix.
-
LeetCode 105 Construct Binary Tree from Preorder and Inorder Traversal
Solutions for LeetCode 105, medium, tags: array, hash table, divide and conquer, tree, binary tree.
-
LeetCode 133 Clone Graph
Solutions for LeetCode 133, medium, tags: hash table, depth-first search, breadth-first search, graph.
-
LeetCode 424 Longest Repeating Character Replacement
Solutions for LeetCode 424, medium, tags: string, sliding window, hash table, binary search.
-
LeetCode 2583 Kth Largest Sum in a Binary Tree
Solutions for LeetCode 2583, medium, tags: tree, breadth-first search, sorting, binary tree.
-
LeetCode 46 Permutations
Solutions for LeetCode 46, medium, tags: array, backtracking.
-
LeetCode 198 House Robber
Solutions for LeetCode 198, medium, tags: array, dynamic programming.
Recent Posts
-
System Design - How Virtual Memory and Paging Works
How virtual memory and paging works in modern operating systems: address translation, page tables, TLB, page faults, multi-level page tables, and a walkthrough of Linux's implementation.
-
System Design - How the CPU Cache Hierarchy Works
How modern CPU caches work: the memory hierarchy from registers to DRAM, cache lines, associativity, write policies, coherence protocols (MESI), and false sharing — with source code examples showing real performance impact.
-
System Design - How Database Sharding Works
How database sharding works: partitioning strategies (hash, range, directory), routing mechanisms, resharding challenges, and how real systems (Vitess, TiDB, DynamoDB, CockroachDB) implement it.
-
System Design - How the Raft Consensus Algorithm Works
How the Raft consensus algorithm works: leader election, log replication, safety guarantees, membership changes, and source code walkthrough from the etcd/raft implementation.
-
System Design - How Memory Allocators Work
How memory allocators work under the hood: malloc/free internals, free lists, splitting and coalescing, the buddy system, arena-based allocators like tcmalloc and jemalloc, and how modern allocators reduce lock contention in multi-threaded programs.
-
LeetCode 17 Letter Combinations of a Phone Number
Solutions for LeetCode 17, medium, tags: hash table, string, backtracking.
-
LeetCode 54 Spiral Matrix
Solutions for LeetCode 54, medium, tags: array, matrix, simulation.
-
System Design - How the Linux Process Scheduler (CFS) Works
How Linux's Completely Fair Scheduler (CFS) works: virtual runtime, red-black tree scheduling, nice values, CPU bandwidth control, and source code walkthrough from the kernel's sched/fair.c.