~/problems
Problems
Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.
Advanced & competitive
Randomness
Random sampling, shuffles and expected value.
18 problems
Advanced & competitive
Randomness Random sampling, shuffles and expected value.
Randomized algorithms
- Play first: The Endless Parade 1-minute game Reservoir sampling
- Roll a die and tally the faces basics py · c++ · java easy
- Plant swap: nobody keeps their own cutting py · c++ · java easy
- Shuffle an array py · c++ · java medium
- Insert Delete GetRandom O(1) py · c++ · java medium
- Random index of a target value py · c++ · java medium
- Random node of a linked list code the boss py · c++ · java medium
- Uniform sample of k items from a stream py · c++ · java medium
- Random pick avoiding a blacklist py · c++ · java medium
Probability and expected value
- Distribution of a dice sum basics py · c++ · java easy
- Surprise scoops: expected flavours tried py · c++ · java easy
- Coupon collector: rolls until every face appears py · c++ · java easy
- Expected maximum of k dice py · c++ · java easy
- Gambler's ruin: chance to reach the target py · c++ · java easy
- Uniform 1..10 from a 1..7 die py · c++ · java medium
- New 21 Game py · c++ · java medium
More practice: 3 problems
- Expected coin flips until a pattern appears py · c++ · java medium
- Optimal execution with a broker backstop Optiver py · c++ · java hard
- Restart strategies for a random solve time assessment 3 levels OpenAI py · c++ · java hard