Topic
Math & Bit Manipulation interview problems
Number theory, combinatorics and bit tricks. 216 original problems, each with hidden test cases you can run in the browser.
84 easy111 medium21 hard
Showing 1–30 of 216 results
Derive and evaluate the closed-form expected value and variance for the number of inversions in a uniformly random permutation.
Auto-gradedmathcombinatoricsstatisticsprobabilityEvaluate floating-point powers with integer exponents using logarithmic time binary exponentiation without standard library power methods.
Auto-gradedmathbinary-exponentiationbit-manipulationFind the optimal sequence of deposit and collection moves to maximize expected value in an unobserved two-container game.
Auto-gradedprobabilityexpected-valuegreedymathLabel each pair of circles by their geometric relationship using exact integer squared-distance comparisons and a strict rule order, including degenerate radius-zero cases.
Auto-gradedgeometryinteger-arithmeticcase-analysissimulationCompute the headcount of two specialist worker types so a component quota splits exactly 2:1 with every worker at full capacity, or report that no such staffing exists.
Auto-gradedmathratiosdivisibilitymodular-arithmeticCalculate the exact win probability in a dice duel where one player uses an optimal single blind reroll strategy.
Auto-gradedmathprobabilitygreedyImplement full-batch gradient descent for a one-feature least-squares line, standardizing the input, and map the learned parameters back to the original scale.
Auto-gradedgradient-descentlinear-regressionnumericalfeature-scalingSimulate customer buy and sell orders against fractional inventory, trading only whole shares with the market, and emit ordered transfer logs and final balances.
Auto-gradedsimulationstring-parsinginteger-arithmetichash-mapCompute the minimum total steps to ferry every item to a single target cell on an open grid, carrying one at a time, using Manhattan distances and a smart choice of the first pickup.
Auto-gradedgreedymanhattan-distancegridmathCount how many runners, released one per time unit, cross a track without ever sharing a cell at the same integer time with a sentry that bounces back and forth inside a fixed range.
Model answersimulationmodular-arithmeticperiodic-motionparityInvert the bit at a given index in a non-negative integer using bitwise operations.
Model answermath-bitsbit-manipulationmathCompute the expected number of same-rank card pairs in a hand drawn without replacement, using linearity of expectation over pairs of cards.
Auto-gradedprobabilityexpectationcombinatoricslinearity-of-expectationComputes the exact binomial tail probability P(X > k) and its Poisson approximation parameterised by lambda = n * p.
Auto-gradedmathstatisticsprobabilitySplit a run of consecutive IPv4 addresses into the fewest aligned power-of-two prefix blocks using 32-bit integer and lowest-set-bit reasoning.
Auto-gradedbit-manipulationgreedyipv4cidrWrite iterative and recursive factorial functions alongside a sequence of integer squares, focusing on input validation, edge cases, and stack vs. loop complexity.
Model answermathrecursioniterationpythonDetermine how many positive integers can serve as the starting element of a sequence of consecutive positive integers that sums to a target value.
Auto-gradedmathnumber-theoryarithmetic-progressionTrack a pool that only grows, sized to cover each load reading with fixed-capacity workers; tests ceiling division and running-maximum reasoning with large values.
Auto-gradedsimulationprefix-maximumceiling-divisionarraysImplement population variance on a list of numbers without external libraries, handling empty and single-element inputs and choosing a numerically sound approach.
Auto-gradedvariancestatisticsfloating-pointarraysFind the smallest palindromic integer strictly larger than a non-negative integer, using the left half of the digits and carry handling, including the all-9s case.
Auto-gradedpalindromedigitsmathcarryCompute the sum of integers from 1 to n divisible by at least one of 3, 5, or 7, counting each integer once, which tests overlap handling and inclusive bounds.
Auto-gradedmathinclusion-exclusioniterationdivisibilityCompute a float raised to a signed 32-bit integer power in logarithmic time and constant space, handling negative exponents, zero bases and the most negative exponent.
Auto-gradedbinary-exponentiationfloating-pointedge-casesiterationFind the prime at a given 1-based position in ascending order, which tests sieving, bounding the search range, and complexity reasoning.
Auto-gradedprimessievenumber-theorymathBuild a cumulative distribution from sampled density points using exact integration of a piecewise-linear curve, then answer many query points with correct boundary behavior.
Auto-gradednumerical-integrationbinary-searchprefix-sumsprobabilityGiven population size and individual adoption probability, calculate key expectation, probability, and conditional probability metrics under Bernoulli assumptions.
Auto-gradedmathprobabilitystatisticsnumerical-methodsDecide whether one positive integer point can become another by repeatedly replacing a coordinate with the coordinate sum, for values up to 10^18, by reversing moves with modulo.
Auto-gradedmatheuclidean-algorithmmoduloreverse-thinkingCompute a birthday-collision threshold exactly and by approximation, plus expected minimum gap and tail probability for random points on a circle, with a Poisson comparison.
Auto-gradedprobabilitymathbirthday-paradoxpoisson-approximationCompute a floating-point base raised to a signed 32-bit integer exponent in logarithmic time, including negative exponents, using repeated squaring.
Auto-gradedbinary-exponentiationmathbit-manipulationfloating-pointBuild a fixed unit-economics report for a card launch: portfolio P&L, partnership uplift, bonus payback time, and the zero-profit loss rate.
Auto-gradedmathsimulationunit-economicsdictionariesGiven selection priors and ball counts for several containers, calculate the posterior probability of drawing from a specific container after observing a target outcome.
Auto-gradedmathprobabilitybayes-theoremarraysThree friends speak under a rule that ties honesty to who owns more cats. Use the statements, parity, divisibility and a sum bound to find Bob's cat count and the triple of counts.
Model answerlogic-puzzlecase-analysisdivisibilityparity