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 1248 Count Number of Nice Subarrays
Solutions for LeetCode 1248, medium, tags: array, hash table, prefix sum, sliding window.
-
LeetCode 1748 Sum of Unique Elements
Use a bounded frequency table in O(n) time, or sort and scan duplicate groups in O(n log n) time.
-
LeetCode 274 H-Index
Solutions for LeetCode 274, medium, tags: array, counting sort, sorting.
-
LeetCode 70 Climbing Stairs
Solution for LeetCode 70, easy, tags: dynamic programming, math.
-
LeetCode 1718 Construct the Lexicographically Largest Valid Sequence
Backtracking solutions for LeetCode 1718, medium, tags: array, backtracking.
-
LeetCode 1624 Largest Substring Between Two Equal Characters
Solutions for LeetCode 1624, easy, tags: hash table, string.
-
LeetCode 94 Binary Tree Inorder Traversal
Solutions for LeetCode 94, easy, tags: tree, depth-first search, stack, binary tree.
-
LeetCode 1013 Partition Array Into Three Parts With Equal Sum
Solutions for LeetCode 1013, easy, tags: array, greedy, prefix sum.
-
LeetCode 1003 Check If Word Is Valid After Substitutions
Solutions for LeetCode 1003, medium, tags: string, stack.
-
LeetCode 1768 Merge Strings Alternately
Solution for LeetCode 1768, easy, tags: string, two pointers.
Recent Posts
-
System Design - How Redis Streams and Consumer Groups Work
Follow a Redis Stream from XADD through consumer-group delivery, pending entries, acknowledgements, and recovery after a worker fails.
-
System Design - How TiDB Index Merge Combines Index Scans
Trace TiDB's union-type Index Merge from a physical plan through parallel index scans, duplicate-handle removal, and a table lookup.
-
AI/ML - How Diffusion Models Generate Images
A beginner-friendly walkthrough of diffusion image generation: how models learn to remove noise, use text prompts, and generate images in compressed latent space.
-
System Design - How TiDB Dynamically Prunes Table Partitions
A source-code walkthrough of TiDB dynamic partition pruning: how a plan carries predicates to execution, selects physical partitions, and builds scans for them.
-
System Design - How TiDB Transactionally Backfills an Index
Trace TiDB's transactional ADD INDEX worker from schema-state changes through row decoding, uniqueness checks, and batched KV writes.
-
System Design - How WireGuard Builds a Secure IP Tunnel
Follow an IP packet through WireGuard's peer routing, Noise handshake, encrypted transport, replay protection, and NAT keepalives.
-
System Design - How TiDB AUTO_INCREMENT Cache Works in Source Code
A focused TiDB source walkthrough of AUTO_ID_CACHE=1: how table metadata selects the allocator service, how it reserves ID ranges, and why failover can leave gaps.
-
System Design - How Terraform Plan and Apply Work
A beginner-friendly walkthrough of Terraform's plan and apply workflow: providers, state, dependency graphs, saved plans, and the API operations that change infrastructure.