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 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).
-
LeetCode 1129 Shortest Path with Alternating Colors
Solutions for LeetCode 1129, medium, tags: graph, breadth-first search.
-
LeetCode 2602 Minimum Operations to Make All Array Elements Equal
Solutions for LeetCode 2602, medium, tags: array, binary search, sorting, prefix sum.
-
LeetCode 2730 Find the Longest Semi-Repetitive Substring
Solutions for LeetCode 2730, medium, tags: string, sliding window, two pointers.
Recent Posts
-
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.
-
System Design - How Apache Airflow Schedules a DAG
A beginner-friendly explanation of Apache Airflow's DAG processor, scheduler, executor, and workers—and how a task becomes eligible to run.
-
System Design - How TiDB Locks Rows for SELECT FOR UPDATE
Trace a pessimistic SELECT FOR UPDATE from TiDB's executor through the TiKV MVCC lock command, including lock waits, timestamp conflicts, and the settings that control them.
-
System Design - How Apache Arrow Works: Columnar Data in Memory
A practical guide to Apache Arrow's in-memory columnar format: arrays, record batches, validity bitmaps, offsets, IPC, Flight, and when zero-copy data sharing is possible.
-
System Design - How TiDB Tracks Query Memory in Source Code
Follow TiDB's memory trackers from StatementContext to the session quota and OOM action, with a focused walkthrough of the current source code and its key settings.
-
System Design - How TiDB Async Commit Works in Source Code
A focused source walkthrough of TiDB Async Commit: how a SQL COMMIT reaches tikv/client-go, how TiKV stores async-commit lock metadata and a minimum commit timestamp, and why TiDB can acknowledge before background lock finalization.
-
AI/ML - How Speculative Decoding Speeds Up LLM Generation
A practical explanation of speculative decoding: how a small draft model proposes tokens, a larger model verifies them in parallel, and rejection sampling preserves the target model's output distribution.