KatInterview

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

Math & Bit Manipulation Interview Problems

Practice 5971 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.

5971
Problems
2211
Auto-graded
15
Topics
272
Added today

Showing 61–90 of 184 results

  • Math & Bit ManipulationEasyAuto-graded
    Possible Subspace Intersection Dimensions

    Computes all valid integer dimensions for the intersection of two vector subspaces given ambient and subspace dimensions.

    Math & Bit Manipulationmathlinear-algebra
  • Math & Bit ManipulationMediumAuto-graded
    Firewall Rule Resolver with Longest-Prefix Priority

    Resolve an IPv4 address against CIDR allow/deny rules using longest-prefix precedence, later-rule tie-breaking, and a default of deny, via bitmask matching.

    Math & Bit Manipulationbit-manipulationcidripv4simulation
  • Math & Bit ManipulationMediumAuto-graded
    Enumerate Every Factor of a Large Integer in Sorted Order

    Produce all positive factors of an integer up to 10^12 in increasing order, handling perfect squares and large primes, and consider approaches faster than a square-root scan.

    Math & Bit Manipulationnumber-theorydivisorsfactorizationsquare-root
  • Math & Bit ManipulationEasyAuto-graded
    Is This Dice Wager Worth Playing? Expected Value Check

    Count outcomes of a two-dice contest where ties favor the house, compute the expected profit per round, and decide whether a risk-neutral player should take the bet.

    Math & Bit Manipulationprobabilityexpected-valuemathcounting
  • Math & Bit ManipulationEasyAuto-graded
    Gaussian Fit Summary: Mean and Two Variance Estimates

    Compute the sample mean, the divide-by-n variance, and the divide-by-(n-1) variance from a list of numbers, tying MLE for a normal model to Bessel's correction.

    Math & Bit Manipulationstatisticsmatharraysfloating-point
  • Math & Bit ManipulationMediumAuto-graded
    Simulate IPv4 CIDR Block Iterator

    Parse IPv4 CIDR blocks and simulate step-by-step traversal over all IP addresses in the subnet range.

    Math & Bit Manipulationbit-manipulationstringsdesignmath
  • Math & Bit ManipulationMediumAuto-graded
    Floor of a Square Root Without Built-ins

    Compute the largest integer whose square does not exceed a non-negative integer, without using built-in roots or powers, using monotonic search or an iterative refinement.

    Math & Bit Manipulationbinary-searchmathnewton-methodinteger-arithmetic
  • Math & Bit ManipulationMediumAuto-graded
    Gambler's Ruin: Chance of Hitting the Goal Before Bust

    Compute the probability that a biased ±1 random walk reaches a target balance before hitting zero, using a recurrence and closed form with careful edge cases.

    Math & Bit Manipulationprobabilitygambler's ruinrecurrencerandom walk
  • Math & Bit ManipulationMediumAuto-graded
    Calculate Minimal Clock Hand Separation Angle

    Parse 24-hour timestamp strings (including optional seconds and milliseconds) and calculate the minor angle between analog clock hands.

    Math & Bit Manipulationmathstringsgeometry
  • Math & Bit ManipulationMediumAuto-graded
    Maximum Area of a Rotated Rectangle

    Find the largest surface area of any rectangle formed by four vertices chosen from a given set of 2D points.

    Math & Bit Manipulationmathgeometryhashingarrays
  • Math & Bit ManipulationEasyAuto-graded
    Min Comparisons to Determine Top Two Elements

    Calculate the theoretical minimum number of comparisons needed in the worst case to locate both the largest and second-largest elements among N items.

    Math & Bit Manipulationmathsortingalgorithms
  • Math & Bit ManipulationEasyAuto-graded
    Expected Transit Wait Time with Stochastic Delays

    Computes the expected waiting time for a passenger arriving at a random moment at a stop with probabilistic bus delays.

    Math & Bit Manipulationmathprobabilitystatisticsexpected-value
  • Math & Bit ManipulationMediumAuto-graded
    Optimal Warehouse Placement to Minimize Total Delivery Distance

    Find the minimum cumulative Manhattan distance from a single target point to all target locations in a 2D grid.

    Math & Bit Manipulationarraysmathsortinggrid
  • Math & Bit ManipulationEasyAuto-graded
    Exact Binomial Probability of Coin Flips

    Calculates the exact binomial probability of obtaining a specific number of heads across a series of fair coin tosses.

    Math & Bit Manipulationmathprobabilitycombinatorics
  • Math & Bit ManipulationEasyAuto-graded
    Calculate Progressive Income Tax in Cents

    Determine progressive income tax in cents given bracket thresholds and percentage rates using integer math.

    Math & Bit Manipulationmatharrayssimulation
  • Math & Bit ManipulationMediumAuto-graded
    Aggressive Wagering: Chance of Hitting the Goal Before Going Broke

    Model a state-dependent betting strategy as a Markov chain and solve absorption probabilities, including cycles, via a linear system.

    Math & Bit Manipulationprobabilitymarkov-chainlinear-algebragaussian-elimination
  • Math & Bit ManipulationEasyAuto-graded
    Calculate Product Mix Profitability Metrics

    Computes baseline and mix-shifted unit profit averages, per-unit margin delta, and overall impact on profit given total volume.

    Math & Bit Manipulationmatharrays
  • Math & Bit ManipulationEasyAuto-graded
    Simple OLS Linear Regression Fitting

    Compute the slope and intercept for a univariate linear regression model using ordinary least squares.

    Math & Bit Manipulationmatharraysstatistics
  • Math & Bit ManipulationMediumAuto-graded
    Chance That Two Random Draws Multiply to More Than a Half

    Compute the exact probability that the product of two independent Uniform(0,1) values exceeds 1/2, by integrating over the region of the unit square above a hyperbola.

    Math & Bit Manipulationprobabilityintegrationcontinuous-distributionsclosed-form
  • Math & Bit ManipulationHardAuto-graded
    Subset Count Under Sum Constraint and Divisor Index

    Find the maximum number of elements from an array whose sum is at most a given target n, and compute the k-th smallest positive divisor of a number N.

    Math & Bit Manipulationmathsortinggreedyprefix-sum
  • Math & Bit ManipulationMediumAuto-graded
    Determine if Two Coin Stacks Can Be Equalized by Doubling

    Determine if two initial quantities can reach equality through deterministic transfers that double the recipient stack.

    Math & Bit Manipulationmath-bitsnumber-theorybit-manipulationsimulation
  • Math & Bit ManipulationEasyAuto-graded
    Rent and Occupancy Targets for a 100-Unit Apartment Building

    Apply a simple profit model with fixed costs, a rent-proportional cost and a target return to find a required rent and a required occupancy.

    Math & Bit Manipulationmathbreak-evenunit-economicsalgebra
  • Math & Bit ManipulationMediumAuto-graded
    Expected Number of Running Record Highs

    Compute the expected number of strict running maximum records for a uniformly random ordering of a collection of numbers.

    Math & Bit Manipulationmathprobabilityarrays
  • Math & Bit ManipulationEasyAuto-graded
    Posterior for the Favorite After Your Entry Loses

    Apply Bayes' rule to find the chance a randomly chosen contestant was the strongest one, given that it did not win a three-way contest.

    Math & Bit Manipulationprobabilitybayes-ruleconditional-probabilitymath
  • Math & Bit ManipulationEasyAuto-graded
    Determine Convergence of Digit-Square Sums

    Simulate a transformation that replaces a number with the sum of its squared digits, determining if it terminates at 1 or loops indefinitely.

    Math & Bit Manipulationmathhash-tabletwo-pointers
  • Math & Bit ManipulationEasyAuto-graded
    Confusion Matrix Scorecard with Safe Division

    Compute precision, recall, specificity, F1 and accuracy from confusion-matrix counts, returning 0.0 for any metric whose denominator is zero.

    Math & Bit Manipulationmetricsconfusion-matrixedge-casesarithmetic
  • Math & Bit ManipulationEasyAuto-graded
    Probability of Keeping Majority Red Items

    Calculates the probability that at least two of three kept items are red when green items are returned upon selection.

    Math & Bit Manipulationmathcombinatoricsprobability
  • Math & Bit ManipulationMediumAuto-graded
    Chance a Daily +/- Walk Ends Below Zero

    Model a price as a two-step random walk, reduce it to a binomial lower tail with a strict cutoff, and sum that tail in a numerically stable way.

    Math & Bit Manipulationprobabilitybinomialnumerical-stabilityrandom-walk
  • Math & Bit ManipulationEasyAuto-graded
    Calculate Expected Score from Multi-Stage Die Rerolls

    Computes the optimal decision threshold and overall expected payoff when given one optional reroll on an N-sided die.

    Math & Bit Manipulationmathprobabilityexpected-valuedynamic-programming
  • Math & Bit ManipulationEasyAuto-graded
    Determine Animal Quantities in a Barn

    Find the integer count of each animal species given the total legs and proportional species constraints.

    Math & Bit Manipulationmathalgebra