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 399 Evaluate Division
Solutions for LeetCode 399, medium, tags: array, string, depth-first search, breadth-first search, union find, graph, shortest path.
-
LeetCode 373 Find K Pairs with Smallest Sums
Solutions for LeetCode 373, medium, tags: array, heap.
-
LeetCode 901 Online Stock Span
Solutions for LeetCode 901, medium, tags: stack, design, monotonic stack, data stream.
-
LeetCode 437 Path Sum III
Solutions for LeetCode 437, medium, tags: tree, depth-first search, binary tree, prefix sum, hash table.
-
LeetCode 310 Minimum Height Trees
Solutions for LeetCode 310, medium, tags: graph, topological sort, BFS.
-
LeetCode 543 Diameter of Binary Tree
Solutions for LeetCode 543, easy, tags: tree, depth-first search, binary tree.
-
LeetCode 127 Word Ladder
Solutions for LeetCode 127, hard, tags: hash table, string, breadth-first search.
-
LeetCode 2131 Longest Palindrome by Concatenating Two Letter Words
Solutions for LeetCode 2131, medium, tags: array, hash table, string, greedy, counting.
-
LeetCode 210 Course Schedule II
Solutions for LeetCode 210, medium, tags: depth-first search, breadth-first search, graph, topological sort.
-
LeetCode 2101 Detonate the Maximum Bombs
Solutions for LeetCode 2101, medium, tags: array, math, depth-first search, breadth-first search, graph.
Recent Posts
-
System Design - How Memory-Mapped Files (mmap) Work
How memory-mapped files (mmap) work: virtual memory mapping, page faults, kernel page cache interaction, copy-on-write semantics, and why databases love and hate them.
-
System Design - How Futexes Work (The Foundation of Every Lock You Use)
How Linux futexes work: the hybrid userspace/kernel synchronization primitive that powers every mutex, condition variable, and semaphore in modern programs. Covers the fast-path CAS, slow-path syscall, kernel hash table, the three-state mutex optimization, and a source code walkthrough from the Linux kernel and glibc.
-
System Design - How Apache ZooKeeper Works
How Apache ZooKeeper works: the coordination service behind Kafka, Hadoop, and HBase. Covers ZAB consensus protocol, znodes, watches, ephemeral nodes, leader election, sessions, and a source code walkthrough from the apache/zookeeper repository.
-
AI/ML - How BPE Tokenization Works in Large Language Models
How Byte Pair Encoding (BPE) tokenization works in large language models: the training algorithm, encoding and decoding, tiktoken and sentencepiece implementations, vocabulary construction, and why subword tokenization strikes the right balance between characters and words.
-
System Design - How the Linux Kernel Network Stack Works
How a packet travels from NIC hardware to your application's socket: interrupts, NAPI, sk_buff, protocol layers, and socket receive queues — a walkthrough of the Linux kernel network stack.
-
System Design - How Protocol Buffers (Protobuf) Encoding Works
How Protocol Buffers encoding works internally: wire types, varint encoding, field tags, length-delimited records, and a byte-level walkthrough showing why protobuf messages are compact and fast to parse.
-
System Design - How Database Connection Pooling Works
How database connection pooling works: the cost of raw connections, pool lifecycle, idle/active management, connection multiplexing modes, HikariCP internals, and PgBouncer architecture with source code walkthrough.
-
LeetCode 4 Median of Two Sorted Arrays
Solutions for LeetCode 4, hard, tags: array, binary search, divide and conquer.