Generate rand7 from rand5: Rejection Sampling for Random Sources
5 min read Generate Random Numbers in a Range Using a Smaller Random Source “Given rand5() that returns a uniform integer 1–5, implement […] Read article
5 min read Generate Random Numbers in a Range Using a Smaller Random Source “Given rand5() that returns a uniform integer 1–5, implement […] Read article
5 min read Find the Counterfeit Coin: 10 Coins (or N Coins), One Different, Minimum Weighings Counterfeit coin puzzles are a classic interview Read article
4 min read Probability of a Car Passing By: Poisson Process and Inter-Arrival Times “Cars pass a point on a road independently. The Read article
6 min read Missing or Duplicate Number in an Array: XOR, Sum, Cyclic Sort, and Floyd’s Algorithm Finding the missing number or the Read article
5 min read Probability Distribution Functions: PMF, PDF, CDF, and the Common Distributions Understanding probability distribution functions is foundational for quant trading interviews, Read article
5 min read Remove a Character from a String: In-Place, Two-Pointer, and Stream Variants Removing characters from a string is a foundational interview Read article
7 min read Longest Palindromic Substring: Expand Around Center, DP, and Manacher’s Algorithm Finding the longest palindromic substring of a string is one Read article
6 min read Find the Depth (Height) of a Binary Tree: Recursive, Iterative BFS, and Iterative DFS Finding the depth (also called height Read article
6 min read Check If a Number Is a Power of Two: Bit Manipulation, Math, and Variations “Is this number a power of Read article
6 min read Check If a Linked List Is a Palindrome: Stack, Reverse-Half, and Recursive Approaches Palindrome linked list (LeetCode #234) is a Read article
6 min read Producer-Consumer Problem: Bounded Buffer with Locks, Condition Variables, and Modern Approaches The producer-consumer problem is the canonical concurrency interview question. Read article
6 min read Serialize and Deserialize a Binary Tree: Preorder, Level-Order, and Edge Cases Serialize / deserialize a binary tree (LeetCode #297) is Read article
5 min read Compute x^y for Floats and Negative Exponents: Fast Exponentiation Computing pow(x, y) efficiently is LeetCode #50 and a frequently-asked interview Read article
6 min read Reverse a Doubly Linked List: Iterative, Recursive, and the Common Mistakes Reversing a doubly linked list (DLL) is a classic Read article
6 min read Two Sum: Find a Pair in an Array That Sums to a Target Two Sum is the most-asked coding interview Read article