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 992 Subarrays with K Different Integers
Count subarrays with exactly k distinct values by subtracting two sliding-window counts.
-
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.
Recent Posts
-
System Design - How OpenTelemetry Collector Pipelines Work
A practical walkthrough of how the OpenTelemetry Collector receives telemetry, runs it through ordered pipelines, and exports it to observability backends.
-
System Design - How TiDB AUTO_RANDOM IDs Work in Source Code
A small TiDB source walkthrough of AUTO_RANDOM: how an insert combines a shard prefix with an allocated counter, and how that changes clustered row keys.
-
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.