All Posts

Leetcode 808: Soup Servings

You have two types of soup: A and B, with an initial volume of n ml of each. You can serve soup using four possible operations, each with a 25% chance of being chosen randomly. When serving, the amounts of soups A and B used are specified by each operation. If there is insufficient soup for a full operation, serve as much as possible. The process stops when one of the soups runs out. Return the probability that soup A will be exhausted first, plus half the probability that both soups will be exhausted at the same time.

Leetcode 837: New 21 Game

Alice is playing a game where she starts with 0 points and randomly draws a number from the range [1, maxPts] each time. Alice continues drawing until her points reach or exceed a target value k. After each draw, she may stop if her total points reach or exceed k. The goal is to determine the probability that Alice has at most n points before reaching k points.

Leetcode 1093: Statistics from a Large Sample

You are given a dataset of integers in the range [0, 255], represented by an array count where count[k] denotes the frequency of number k in the dataset. From this dataset, compute the following statistics: minimum, maximum, mean, median, and mode.

Leetcode 1227: Airplane Seat Assignment Probability

There are n passengers boarding an airplane with n seats. The first passenger has lost their ticket and picks a random seat. The remaining passengers sit in their assigned seat if available or pick a random seat if their assigned seat is taken. Return the probability that the nth person gets their own seat.