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 1963 Minimum Number of Swaps to Make the String Balanced
An O(n)-time, O(1)-space solution to LeetCode 1963 using unmatched brackets.
-
LeetCode 2215 Find the Difference of Two Arrays
Solution for LeetCode 2215, easy, tags: array, hash table.
-
LeetCode 2000 Reverse Prefix of Word
Solution for LeetCode 2000, easy, tags: string, two pointers.
-
LeetCode 1034 Coloring A Border
Iterative BFS solution for LeetCode 1034, Coloring A Border.
-
LeetCode 2485 Find the Pivot Integer
Solutions for LeetCode 2485, easy, tags: math, prefix sum.
-
LeetCode 1047 Remove All Adjacent Duplicates In String
Solution for LeetCode 1047, easy, tags: string, stack, simulation.
-
LeetCode 1657 Determine if Two Strings Are Close
Solution for LeetCode 1657, medium, tags: hash table, string, sorting, counting.
-
LeetCode 946 Validate Stack Sequences
Solution for LeetCode 946, medium, tags: array, stack, simulation.
-
LeetCode 2574 Left and Right Sum Differences
Solution for LeetCode 2574, easy, tags: array, prefix sum.
-
LeetCode 2140 Solving Questions With Brainpower
Solution for LeetCode 2140, medium, tags: array, dynamic programming.
Recent Posts
-
System Design - How a Count-Min Sketch Estimates Frequencies
Follow a small stream through the counters of a count-min sketch, see why collisions only overestimate counts, and learn when its memory and error guarantees are useful.
-
System Design - How TiDB's EXPLAIN Executor Produces Plan Rows
Trace a SELECT's EXPLAIN and EXPLAIN ANALYZE through TiDB's planner, executor builder, and ExplainExec to see when SQL runs and how plan rows reach the client.
-
System Design - How Backpressure Protects a Flink Stream Pipeline
Follow a slow Flink sink backward through network buffers, receiver credits, and upstream tasks to see why bounded queues protect a streaming pipeline.
-
System Design - How TiDB Batch Point Get Fetches Unique Keys
Walk through TiDB's BatchPointGetPlan, executor builder, and BatchPointGetExec as an IN-list on a unique secondary index becomes two KV batch reads.
-
System Design - How Fencing Tokens Stop Stale Lock Holders
Why a distributed lease cannot stop a paused worker from writing, and how ordered fencing tokens let a storage system reject stale requests.
-
System Design - How TiDB Checks a Scalar Subquery's Row Count
Follow TiDB's LogicalMaxOneRow, PhysicalMaxOneRow, executor builder, and MaxOneRowExec through the zero-, one-, and many-row cases.
-
System Design - How TiDB's Parallel Sort Executor Merges Rows
Trace TiDB's PhysicalSort, SortExec, parallelSortWorker, and multiWayMerger as they sort chunks and merge worker results, with memory and spill settings.
-
System Design - How Database Group Commit Amortizes fsync
Follow three concurrent PostgreSQL commits through WAL positions, one shared flush, and the latency-throughput trade-off of commit_delay.