KatInterview

practice a little every day — you've got this ♡

Math & Bit Manipulation Interview Problems

Practice 5972 original coding, SQL, system design, machine learning and behavioral problems across 15 topics. Coding and SQL problems run against hidden test cases right in your browser; every problem has hints and a worked solution, free.

5972
Problems
2212
Auto-graded
15
Topics
273
Added today

Showing 121–150 of 217 results

  • Math & Bit ManipulationEasyAuto-graded
    Feed Ad Load: Random Slots vs. Fixed Block Quota

    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.

    Math & Bit Manipulationprobabilityexpectationmathcomplement-rule
  • Math & Bit ManipulationMediumAuto-graded
    Tie-Aware Ranking Probabilities for Three and Four Tasters

    Derive conditional ranking probabilities for i.i.d. scores, with and without ties, and return them as a dictionary keyed by named quantities.

    Math & Bit Manipulationprobabilitycombinatoricsconditional-probabilityclosed-form
  • Math & Bit ManipulationMediumModel answer
    Stable Softmax, Sliding Variance and Balanced Partition

    Three 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.

    Math & Bit Manipulationsoftmaxnumerical-stabilitywelfordsliding-window
  • Math & Bit ManipulationEasyAuto-graded
    Annual Profit and Break-Even Value for a Lounge Menu Item

    Compute 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.

    Math & Bit Manipulationarithmeticbreak-evensimulationedge-cases
  • Math & Bit ManipulationEasyAuto-graded
    Lamps After Divisor Sweeps

    Count how many of n switches end up on after sweeping by every step size, which tests the divisor-parity and perfect-square insight.

    Math & Bit Manipulationmathnumber-theoryperfect-squaresdivisors
  • Math & Bit ManipulationHardAuto-graded
    Can a Starting Pair Grow Into a Goal Pair by Summing Coordinates?

    Decide 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.

    Math & Bit Manipulationmatheuclidean-algorithmreverse-thinkingmodulo
  • Math & Bit ManipulationHardAuto-graded
    Fewest Presses to Morph One Light Grid Into Another

    Find 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.

    Math & Bit Manipulationgaussian-eliminationgf2bitmasklinear-algebra
  • Math & Bit ManipulationMediumModel answer
    Bit-Level Speedups for a Hot Integer Loop

    Choose 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.

    Math & Bit Manipulationbit-manipulationbranchlesspopcountperformance
  • Math & Bit ManipulationEasyAuto-graded
    Smallest Equicorrelation Value for a Valid 3x3 Matrix

    Determine 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.

    Math & Bit Manipulationlinear-algebraeigenvaluespositive-semidefinitemath
  • Math & Bit ManipulationMediumAuto-graded
    Matrix Product, Fast Power and Fibonacci Toolkit

    Combine matrix multiplication, square-and-multiply exponentiation and 2x2 matrix-power Fibonacci, with optional modular arithmetic, in one function.

    Math & Bit Manipulationmatrix-multiplicationfast-exponentiationfibonaccimodular-arithmetic
  • Math & Bit ManipulationHardAuto-graded
    Ordered IPv4 Access List: Verdict for an Address or Entire Subnet

    Evaluate 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.

    Math & Bit Manipulationcidrbit-manipulationstacksorting
  • Math & Bit ManipulationEasyAuto-graded
    Expected Draws Until a Second Distinct Token Shows Up

    Compute, 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.

    Math & Bit Manipulationprobabilityexpected-valuegeometric-distributionmath
  • Math & Bit ManipulationMediumModel answer
    Back-Calculating a Kayak Trip's Start Time from River Speeds

    Two 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.

    Math & Bit Manipulationword-problemrelative-velocityrate-time-distancealgebra
  • Math & Bit ManipulationEasyAuto-graded
    Equal-Sized Uniform Piles From a Card Collection

    Decide 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.

    Math & Bit Manipulationgcdhash-mapcountingnumber-theory
  • Math & Bit ManipulationEasyAuto-graded
    Mean of a Numeric List with Empty-Input Fallback

    Compute the arithmetic mean of a list of numbers, returning 0 for an empty list, testing basic edge-case handling and complexity reasoning.

    Math & Bit Manipulationarraysmathedge-cases
  • Math & Bit ManipulationMediumAuto-graded
    Correlation Bounds, Equicorrelated Triples, and Box-Muller Sampling

    Compute a feasible correlation interval, give coefficients for three equally anti-correlated variables, and convert uniform values to normals with the Box-Muller transform.

    Math & Bit Manipulationprobabilitycorrelationbox-mullersimulation
  • Math & Bit ManipulationEasyAuto-graded
    Eventual Winner Odds in a Draw-Two Card Duel with Replays

    Compute the probability that the first of two drawers eventually wins a rank-comparison game with replayed ties, using counting and a symmetry argument.

    Math & Bit Manipulationprobabilitysymmetrycountingmath
  • Math & Bit ManipulationMediumAuto-graded
    Gambler's Ruin: Success Probability and Duration Score

    Compute 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.

    Math & Bit Manipulationprobabilitymarkov-chainclosed-formnumerical-stability
  • Math & Bit ManipulationEasyAuto-graded
    Dice Duel Wager: Expected Profit and Play Decision

    Compute the expected profit of a two-dice wager where ties favor the opponent, and decide whether a risk-neutral player should accept it.

    Math & Bit Manipulationprobabilityexpected-valuemathdice
  • Math & Bit ManipulationEasyAuto-graded
    Five Quick Probability Puzzles: Dice, Deck, Coins, Boxes

    Work out five small probability puzzles using symmetry, complements, counting and pigeonhole, and return the exact answers as fraction strings in order.

    Math & Bit Manipulationprobabilitycombinatoricspigeonholesymmetry
  • Math & Bit ManipulationEasyAuto-graded
    Sales Volume Needed to Hold Margin After a Menu Expansion

    Derive a closed-form sales volume that keeps profit margin unchanged after adding a second product with extra fixed costs, and reject unreachable targets.

    Math & Bit Manipulationmathalgebrabreak-evenprofit-margin
  • Math & Bit ManipulationEasyAuto-graded
    Factorial Trailing Zeros Without Building the Factorial

    Count the base-10 trailing zeros of n! by tallying factors of 5, never constructing the enormous factorial itself.

    Math & Bit Manipulationmathnumber-theoryfactorialcounting
  • Math & Bit ManipulationMediumAuto-graded
    Minimize Expected Candidates with Position-Match Feedback

    Tests ability to model a greedy partitioning strategy using bitmask bucketing to minimize expected remaining candidates under green-only feedback.

    Math & Bit Manipulationgreedybitmaskhashing
  • Math & Bit ManipulationMediumAuto-graded
    32-Bit Integer Product via Shift-and-Add

    Tests mastery of bitwise arithmetic, sign handling, two's-complement overflow semantics, and O(log n) shift-and-add multiplication without using * or /.

    Math & Bit Manipulationbit-manipulationmathoverflowtwo's-complement
  • Math & Bit ManipulationMediumAuto-graded
    Tank Filling: Can You Hit an Exact Volume?

    Tests whether a candidate can apply GCD-based number theory and state-space reasoning to determine if a target volume is reachable with two containers.

    Math & Bit Manipulationmathbfsnumber-theory
  • Math & Bit ManipulationMediumModel answer
    Square Root by Newton's Method and Odd/Even Index Partitioning

    Implement 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.

    Math & Bit Manipulationnewton-methodquickselectin-place-partitionnumerical-precision
  • Math & Bit ManipulationEasyAuto-graded
    Compute Tax Using Marginal Brackets

    Tests understanding of piecewise rate application and interval-based accumulation in a tiered tax system.

    Math & Bit Manipulationsimulationmathiteration
  • Math & Bit ManipulationMediumAuto-graded
    Two-Year Show Profit: Renewal vs. New Launch

    Compute two-year profits for two show options, blend the new show's outcomes by success probability, and find the break-even probability.

    Math & Bit Manipulationarithmeticexpected-valuebreak-evenbusiness-math
  • Math & Bit ManipulationMediumAuto-graded
    Fewest Steps to Reach One

    Tests greedy reasoning over binary structure to find the minimum number of halving and increment/decrement steps needed to reduce a positive integer to 1.

    Math & Bit Manipulationgreedybit-manipulationmath
  • Math & Bit ManipulationHardAuto-graded
    Decompose an IP Range into the Fewest CIDR Blocks

    Tests greedy interval tiling and bit manipulation by converting an inclusive IPv4 address range into the minimum list of valid, aligned CIDR blocks.

    Math & Bit Manipulationbit-manipulationgreedynetworking