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
-
System Design - How Rate Limiting Works
How rate limiting works: token bucket, leaky bucket, fixed window counter, and sliding window log/counter algorithms with ASCII diagrams, source code walkthrough from Nginx, Guava, and Redis, and practical trade-offs.
-
LeetCode 2452 Words Within Two Edits of Dictionary
Solutions for LeetCode 2452, medium, tags: array, string, trie.
-
LeetCode 907 Sum of Subarray Minimums
Solutions for LeetCode 907, medium, tags: array, dynamic programming, stack, monotonic stack.
-
LeetCode 300 Longest Increasing Subsequence
Solutions for LeetCode 300, medium, tags: array, binary search, dynamic programming.
-
LeetCode 15 3Sum
Solutions for LeetCode 15, medium, tags: array, two pointers, sorting, hash table.
-
LeetCode 33 Search in Rotated Sorted Array
Solutions for LeetCode 33, medium, tags: array, binary search.
-
LeetCode 230 Kth Smallest Element in a BST
Solutions for LeetCode 230, medium, tags: tree, depth-first search, binary search tree, binary tree.
-
LeetCode 347 Top K Frequent Elements
Solutions for LeetCode 347, medium, tags: array, hash table, divide and conquer, sorting, heap, bucket sort, counting, quickselect.
-
LeetCode 155 Min Stack
Solutions for LeetCode 155, medium, tags: stack, design.
Recent Posts
-
System Design - How DNS Resolution Works
How DNS resolution works: the recursive and iterative query process, DNS record types, caching layers, TTL mechanics, and how the global DNS hierarchy routes billions of lookups every day.
-
System Design - How Database Query Optimization Works
How database query optimizers work: parsing SQL into trees, generating candidate plans, cost estimation, join ordering with dynamic programming and genetic algorithms, and a source code walkthrough of the PostgreSQL optimizer.
-
AI/ML - How the Transformer Attention Mechanism Works
How the Transformer attention mechanism works: intuition behind queries/keys/values, scaled dot-product attention, multi-head attention, positional encoding, and a source code walkthrough from PyTorch and the original paper.
-
System Design - How the TLS Handshake Works
How TLS (Transport Layer Security) works: the handshake protocol, certificate verification, key exchange with Diffie-Hellman, symmetric encryption, TLS 1.2 vs 1.3, and a source code walkthrough from Go's crypto/tls package.
-
System Design - How Apache Kafka Works
How Apache Kafka works internally: the distributed commit log, partitions, replication with ISR, producer batching, consumer groups, zero-copy transfer, and source code walkthrough from the apache/kafka repository.
-
LeetCode 49 Group Anagrams
Solutions for LeetCode 49, medium, tags: array, hash table, string, sorting.
-
System Design - How gRPC Works
How gRPC works under the hood: Protocol Buffers serialization, HTTP/2 framing, the four RPC patterns (unary, server streaming, client streaming, bidirectional), channel and transport architecture, interceptors, and a source code walkthrough from the grpc/grpc-go repository.
-
LeetCode 238 Product of Array Except Self
Solutions for LeetCode 238, medium, tags: array, prefix sum.