KatInterview

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

Math & Bit Manipulation Interview Problems

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

5966
Problems
2209
Auto-graded
15
Topics
271
Added today

Showing 1–30 of 217 results

  • Math & Bit ManipulationMediumAuto-graded
    Largest Letter Coverage from Non-Overlapping Words

    Choose words with no repeated letters that share no letters with each other, maximizing total letters covered; tests bitmask encoding and pruned backtracking.

    Math & Bit Manipulationbitmaskbacktrackingset-packingpruning
  • Math & Bit ManipulationEasyAuto-graded
    Theoretical Mean and Variance of Permutation Inversions

    Derive and evaluate the closed-form expected value and variance for the number of inversions in a uniformly random permutation.

    Math & Bit Manipulationmathcombinatoricsstatisticsprobability
  • Math & Bit ManipulationMediumAuto-graded
    Implement Binary Exponentiation

    Evaluate floating-point powers with integer exponents using logarithmic time binary exponentiation without standard library power methods.

    Math & Bit Manipulationmathbinary-exponentiationbit-manipulation
  • Math & Bit ManipulationMediumAuto-graded
    Maximize Expected Return in Two Opaque Containers Game

    Find the optimal sequence of deposit and collection moves to maximize expected value in an unobserved two-container game.

    Math & Bit Manipulationprobabilityexpected-valuegreedymath
  • Math & Bit ManipulationEasyAuto-graded
    Circle Pair Relationship Labeler

    Label each pair of circles by their geometric relationship using exact integer squared-distance comparisons and a strict rule order, including degenerate radius-zero cases.

    Math & Bit Manipulationgeometryinteger-arithmeticcase-analysissimulation
  • Math & Bit ManipulationEasyAuto-graded
    Exact Staffing for a 2:1 Nail-to-Screw Quota

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

    Math & Bit Manipulationmathratiosdivisibilitymodular-arithmetic
  • Math & Bit ManipulationEasyAuto-graded
    Dice Duel Probability with Optional Blind Reroll

    Calculate the exact win probability in a dice duel where one player uses an optimal single blind reroll strategy.

    Math & Bit Manipulationmathprobabilitygreedy
  • Math & Bit ManipulationMediumAuto-graded
    Fit a Line by Batch Gradient Descent with Standardized Input

    Implement full-batch gradient descent for a one-feature least-squares line, standardizing the input, and map the learned parameters back to the original scale.

    Math & Bit Manipulationgradient-descentlinear-regressionnumericalfeature-scaling
  • Math & Bit ManipulationMediumAuto-graded
    Whole-Share Rebalancing for a Fractional Stock Ledger

    Simulate customer buy and sell orders against fractional inventory, trading only whole shares with the market, and emit ordered transfer logs and final balances.

    Math & Bit Manipulationsimulationstring-parsinginteger-arithmetichash-map
  • Math & Bit ManipulationMediumAuto-graded
    Cheapest Acorn Delivery Route for a Chipmunk on a Grid

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

    Math & Bit Manipulationgreedymanhattan-distancegridmath
  • Math & Bit ManipulationMediumModel answer
    Runners Dodging Bouncing Sentries Along a Track

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

    Math & Bit Manipulationsimulationmodular-arithmeticperiodic-motionparity
  • Math & Bit ManipulationEasyModel answer
    Invert Bit at Specific Index

    Invert the bit at a given index in a non-negative integer using bitwise operations.

    Math & Bit Manipulationmath-bitsbit-manipulationmath
  • Math & Bit ManipulationMediumAuto-graded
    Expected Matching-Rank Pairs in a Random Card Hand

    Compute the expected number of same-rank card pairs in a hand drawn without replacement, using linearity of expectation over pairs of cards.

    Math & Bit Manipulationprobabilityexpectationcombinatoricslinearity-of-expectation
  • Math & Bit ManipulationEasyAuto-graded
    Binomial and Poisson Rare Event Tail Probabilities

    Computes the exact binomial tail probability P(X > k) and its Poisson approximation parameterised by lambda = n * p.

    Math & Bit Manipulationmathstatisticsprobability
  • Math & Bit ManipulationMediumAuto-graded
    Cover an IPv4 Address Run with the Fewest Prefix Blocks

    Split a run of consecutive IPv4 addresses into the fewest aligned power-of-two prefix blocks using 32-bit integer and lowest-set-bit reasoning.

    Math & Bit Manipulationbit-manipulationgreedyipv4cidr
  • Math & Bit ManipulationEasyModel answer
    Implement Iterative and Recursive Factorial with Integer Squares

    Write iterative and recursive factorial functions alongside a sequence of integer squares, focusing on input validation, edge cases, and stack vs. loop complexity.

    Math & Bit Manipulationmathrecursioniterationpython
  • Math & Bit ManipulationMediumAuto-graded
    Count Starting Numbers for Consecutive Sums

    Determine how many positive integers can serve as the starting element of a sequence of consecutive positive integers that sums to a target value.

    Math & Bit Manipulationmathnumber-theoryarithmetic-progression
  • Math & Bit ManipulationMediumAuto-graded
    Growing Worker Pool Sized by Peak Load Readings

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

    Math & Bit Manipulationsimulationprefix-maximumceiling-divisionarrays
  • Math & Bit ManipulationEasyAuto-graded
    Spread of a Number List: Population Variance

    Implement population variance on a list of numbers without external libraries, handling empty and single-element inputs and choosing a numerically sound approach.

    Math & Bit Manipulationvariancestatisticsfloating-pointarrays
  • Math & Bit ManipulationMediumAuto-graded
    Smallest Palindrome Above a Given Number

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

    Math & Bit Manipulationpalindromedigitsmathcarry
  • Math & Bit ManipulationEasyAuto-graded
    Total of Numbers Sharing a Factor of 3, 5, or 7

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

    Math & Bit Manipulationmathinclusion-exclusioniterationdivisibility
  • Math & Bit ManipulationMediumAuto-graded
    Integer Power via Repeated Squaring

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

    Math & Bit Manipulationbinary-exponentiationfloating-pointedge-casesiteration
  • Math & Bit ManipulationEasyAuto-graded
    Locate the Prime at a Given Position in the Prime Sequence

    Find the prime at a given 1-based position in ascending order, which tests sieving, bounding the search range, and complexity reasoning.

    Math & Bit Manipulationprimessievenumber-theorymath
  • Math & Bit ManipulationMediumAuto-graded
    Evaluate a Normalized CDF from Piecewise-Linear Density Samples

    Build a cumulative distribution from sampled density points using exact integration of a piecewise-linear curve, then answer many query points with correct boundary behavior.

    Math & Bit Manipulationnumerical-integrationbinary-searchprefix-sumsprobability
  • Math & Bit ManipulationEasyAuto-graded
    Compute Multi-User Feature Adoption Metrics

    Given population size and individual adoption probability, calculate key expectation, probability, and conditional probability metrics under Bernoulli assumptions.

    Math & Bit Manipulationmathprobabilitystatisticsnumerical-methods
  • Math & Bit ManipulationHardAuto-graded
    Reachability Under Sum-Replacement Moves on a Grid

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

    Math & Bit Manipulationmatheuclidean-algorithmmoduloreverse-thinking
  • Math & Bit ManipulationMediumAuto-graded
    Group Size Threshold and Closest-Pair Gap on a Circle

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

    Math & Bit Manipulationprobabilitymathbirthday-paradoxpoisson-approximation
  • Math & Bit ManipulationMediumAuto-graded
    Exponentiation by Squaring with Negative Exponents

    Compute a floating-point base raised to a signed 32-bit integer exponent in logarithmic time, including negative exponents, using repeated squaring.

    Math & Bit Manipulationbinary-exponentiationmathbit-manipulationfloating-point
  • Math & Bit ManipulationEasyAuto-graded
    Card Launch Unit Economics Report Builder

    Build a fixed unit-economics report for a card launch: portfolio P&L, partnership uplift, bonus payback time, and the zero-profit loss rate.

    Math & Bit Manipulationmathsimulationunit-economicsdictionaries
  • Math & Bit ManipulationEasyAuto-graded
    Calculate Bag Selection Probability via Bayes' Theorem

    Given selection priors and ball counts for several containers, calculate the posterior probability of drawing from a specific container after observing a target outcome.

    Math & Bit Manipulationmathprobabilitybayes-theoremarrays