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 2140 Solving Questions With Brainpower
Solution for LeetCode 2140, medium, tags: array, dynamic programming.
-
LeetCode 1696 Jump Game VI
Solutions for LeetCode 1696, medium, tags: array, dynamic programming, sliding window, monotonic queue, heap.
-
LeetCode 2419 Longest Subarray With Maximum Bitwise AND
Solution for LeetCode 2419, medium, tags: array, bit manipulation.
-
LeetCode 1480 Running Sum of 1d Array
Solutions for LeetCode 1480, easy, tags: array, prefix sum.
-
LeetCode 2053 Kth Distinct String in an Array
Solutions for LeetCode 2053, easy, tags: array, hash table, string.
-
LeetCode 1493 Longest Subarray of 1's After Deleting One Element
Solutions for LeetCode 1493, medium, tags: array, sliding window, prefix sum.
-
LeetCode 1207 Unique Number of Occurrences
Solutions for LeetCode 1207, easy, tags: array, hash table.
-
LeetCode 2352 Equal Row and Column Pairs
Solutions for LeetCode 2352, medium, tags: array, hash table, matrix.
-
LeetCode 1827 Minimum Operations to Make the Array Increasing
Solution for LeetCode 1827, easy, tags: array, greedy. One pass in Java, Python, C++, and Rust.
-
LeetCode 2530 Maximal Score After Applying K Operations
Solution for LeetCode 2530, medium, tags: array, greedy, heap (priority queue).
Recent Posts
-
System Design - How TiDB's TopN Executor Keeps Only the Best Rows
Trace ORDER BY with OFFSET and LIMIT through TiDB's PhysicalTopN, executor builder, TopNExec, and chunk heap, including memory and spill settings.
-
System Design - How HyperLogLog Counts Distinct Values
Follow a visitor from a hash to a HyperLogLog register, then see how Redis estimates and merges distinct counts without keeping the visitors themselves.
-
System Design - How TiDB's Selection Executor Filters Chunks
Trace a root Selection from PhysicalSelection through executorBuilder and SelectionExec to a vectorized filter, including its row-at-a-time fallback and chunk controls.
-
System Design - How TLS Certificate Revocation Reaches a Browser
Follow a compromised TLS certificate from CA revocation through CRLs and OCSP to browser checks, and see why freshness and privacy complicate the design.
-
System Design - How TiDB's LIMIT Executor Reads Only Enough Rows
Trace LIMIT with OFFSET through TiDB's PhysicalLimit, executorBuilder, LimitExec, and Chunk, including how chunk demand and session settings affect reads.
-
System Design - How Kubernetes Horizontal Pod Autoscaling Works
Follow a traffic spike through Kubernetes' HPA control loop: metric collection, replica calculations, the scale subresource, and the safeguards against noisy measurements.
-
System Design - How a TCP Connection Opens and Closes
Follow one TCP connection from SYN to TIME-WAIT: sequence numbers, the three-way handshake, half-close, FIN versus RST, and why the active closer lingers.
-
System Design - How TiDB Writes and Reads Its Slow Query Log
A source-level tour of TiDB's slow SQL path: ExecStmt's duration gate, SlowQueryLogItems formatting, the file logger, and the SLOW_QUERY virtual table.