Topic
Math & Bit Manipulation interview problems
Number theory, combinatorics and bit tricks. 217 original problems, each with hidden test cases you can run in the browser.
84 easy112 medium21 hard
Showing 121–150 of 217 results
Compute expected ad counts for two feed ad policies and the chance of seeing at least one ad in a window, using linearity of expectation and the complement rule.
Auto-gradedprobabilityexpectationmathcomplement-ruleDerive conditional ranking probabilities for i.i.d. scores, with and without ties, and return them as a dictionary keyed by named quantities.
Auto-gradedprobabilitycombinatoricsconditional-probabilityclosed-formThree short coding tasks: an overflow-safe softmax, an O(1) sliding-window variance with a ring buffer, and splitting positive integers into two groups with the smallest sum gap.
Model answersoftmaxnumerical-stabilitywelfordsliding-windowCompute a per-site annual operating result and the break-even per-unit benefit from visit volume, uptake rate, unit cost, unit benefit, a one-time setup cost, and a time horizon.
Auto-gradedarithmeticbreak-evensimulationedge-casesCount how many of n switches end up on after sweeping by every step size, which tests the divisor-parity and perfect-square insight.
Auto-gradedmathnumber-theoryperfect-squaresdivisorsDecide whether a goal pair is reachable from a start pair by replacing one coordinate with the sum of both, using a reverse walk with Euclid-style modulo jumps for values up to 10^9.
Auto-gradedmatheuclidean-algorithmreverse-thinkingmoduloFind the smallest set of cell presses that turns one on/off grid into another, where each press flips a cell and its neighbours. Tests GF(2) elimination and null-space minimisation.
Auto-gradedgaussian-eliminationgf2bitmasklinear-algebraChoose bit-twiddling techniques that cut branch mispredictions and memory traffic in a tight integer loop, justify their correctness, and reason about their CPU and cache effects.
Model answerbit-manipulationbranchlesspopcountperformanceDetermine the least real parameter for which a 3x3 symmetric matrix with unit diagonal and equal off-diagonal entries is positive semidefinite, using eigenvalue or minor analysis.
Auto-gradedlinear-algebraeigenvaluespositive-semidefinitemathCombine matrix multiplication, square-and-multiply exponentiation and 2x2 matrix-power Fibonacci, with optional modular arithmetic, in one function.
Auto-gradedmatrix-multiplicationfast-exponentiationfibonaccimodular-arithmeticEvaluate an ordered first-match IPv4 access list for a single address or a whole CIDR block, which needs prefix arithmetic and interval reasoning rather than enumerating addresses.
Auto-gradedcidrbit-manipulationstacksortingCompute, as a floating-point number, the expected number of draws from a fixed three-outcome distribution until two different outcomes have appeared, using conditioning and geometric waiting times.
Auto-gradedprobabilityexpected-valuegeometric-distributionmathTwo paddlers' first-day upstream and downstream legs fix their paddling speed. Use it to find when they must leave on day two to reach a point 23 miles upstream by 16:00.
Model answerword-problemrelative-velocityrate-time-distancealgebraDecide whether a multiset of integers can be split into uniform piles that all share one common size of at least two, testing counting and the GCD insight.
Auto-gradedgcdhash-mapcountingnumber-theoryCompute the arithmetic mean of a list of numbers, returning 0 for an empty list, testing basic edge-case handling and complexity reasoning.
Auto-gradedarraysmathedge-casesCompute a feasible correlation interval, give coefficients for three equally anti-correlated variables, and convert uniform values to normals with the Box-Muller transform.
Auto-gradedprobabilitycorrelationbox-mullersimulationCompute the probability that the first of two drawers eventually wins a rank-comparison game with replayed ties, using counting and a symmetry argument.
Auto-gradedprobabilitysymmetrycountingmathCompute the chance a random walk hits a target before zero using a closed form, handling the fair case and overflow, and return a fixed duration formula.
Auto-gradedprobabilitymarkov-chainclosed-formnumerical-stabilityCompute the expected profit of a two-dice wager where ties favor the opponent, and decide whether a risk-neutral player should accept it.
Auto-gradedprobabilityexpected-valuemathdiceWork out five small probability puzzles using symmetry, complements, counting and pigeonhole, and return the exact answers as fraction strings in order.
Auto-gradedprobabilitycombinatoricspigeonholesymmetryDerive a closed-form sales volume that keeps profit margin unchanged after adding a second product with extra fixed costs, and reject unreachable targets.
Auto-gradedmathalgebrabreak-evenprofit-marginCount the base-10 trailing zeros of n! by tallying factors of 5, never constructing the enormous factorial itself.
Auto-gradedmathnumber-theoryfactorialcountingTests ability to model a greedy partitioning strategy using bitmask bucketing to minimize expected remaining candidates under green-only feedback.
Auto-gradedgreedybitmaskhashingTests mastery of bitwise arithmetic, sign handling, two's-complement overflow semantics, and O(log n) shift-and-add multiplication without using * or /.
Auto-gradedbit-manipulationmathoverflowtwo's-complementTests whether a candidate can apply GCD-based number theory and state-space reasoning to determine if a target volume is reachable with two containers.
Auto-gradedmathbfsnumber-theoryImplement sqrt from scratch with range reduction plus Newton's method, and rearrange an array in O(1) space so even-positioned values all beat odd-positioned ones.
Model answernewton-methodquickselectin-place-partitionnumerical-precisionTests understanding of piecewise rate application and interval-based accumulation in a tiered tax system.
Auto-gradedsimulationmathiterationCompute two-year profits for two show options, blend the new show's outcomes by success probability, and find the break-even probability.
Auto-gradedarithmeticexpected-valuebreak-evenbusiness-mathTests greedy reasoning over binary structure to find the minimum number of halving and increment/decrement steps needed to reduce a positive integer to 1.
Auto-gradedgreedybit-manipulationmathTests greedy interval tiling and bit manipulation by converting an inclusive IPv4 address range into the minimum list of valid, aligned CIDR blocks.
Auto-gradedbit-manipulationgreedynetworking