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 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.
-
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.
-
LeetCode 209 Minimum Size Subarray Sum
Solutions for LeetCode 209, medium, tags: array, binary search, sliding window, prefix sum.
-
LeetCode 121 Best Time to Buy and Sell Stock
Solutions for LeetCode 121, easy, tags: array, dynamic programming.
Recent Posts
-
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.
-
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.
-
System Design - How Linux io_uring Works
How Linux io_uring works: the submission and completion ring buffers, zero-copy I/O without system call overhead, kernel polling mode, and source code walkthrough from the liburing library.
-
System Design - How Two-Phase Commit (2PC) Works
How two-phase commit (2PC) works in distributed databases: the coordinator/participant model, prepare and commit phases, failure handling, recovery via write-ahead logging, and real-world implementations in PostgreSQL, MySQL, and TiDB.
-
LeetCode 143 Reorder List
Solutions for LeetCode 143, medium, tags: linked list, two pointers, stack, recursion.
-
System Design - How Vector Databases Work
How vector databases work: embedding vectors, similarity search, indexing with HNSW and IVF, distance metrics, quantization, and a look at how Milvus organizes its storage engine.