KatInterview

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

Math & Bit Manipulation Interview Problems

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

5967
Problems
2210
Auto-graded
15
Topics
272
Added today

Showing 1–30 of 33 results

  • 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 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 ManipulationEasyModel answer
    Three Cat Owners and a Truth-or-Lie Rule: Find Bob's Count

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

    Math & Bit Manipulationlogic-puzzlecase-analysisdivisibilityparity
  • Math & Bit ManipulationEasyModel answer
    Counting Iterations of a C Loop With an Assignment Condition

    Work out how many times a C for-loop body runs when its condition is an assignment expression rather than a comparison, and explain the final variable values.

    Math & Bit Manipulationc-languagecontrol-flowoperatorsassignment-expression
  • Math & Bit ManipulationMediumModel answer
    Build an Endless Fibonacci Stream with Python Generators

    Explain how lazy evaluation works in Python and write a generator that yields Fibonacci numbers indefinitely, with safe ways to consume it and the reasoning behind its state handling.

    Math & Bit Manipulationpythongeneratorslazy-evaluationfibonacci
  • Math & Bit ManipulationMediumModel answer
    Compute Courier Compensation for Delivery Trips

    Calculate total delivery earnings from start/end times and distances using conditional rates, rush-hour multipliers, and precision rules.

    Math & Bit Manipulationmathparsingsimulation
  • Math & Bit ManipulationMediumModel answer
    Eight Number Puzzles: Spot the Rule, Predict the Next Value

    Work out the hidden rule behind eight short numeric and fractional sequences, state the next term for each, and justify it against every given term.

    Math & Bit Manipulationsequencespattern-recognitionrecurrence-relationsmental-math
  • Math & Bit ManipulationHardModel answer
    Balanced Character Rewriting and Offline Grid Threshold Queries

    Solve parity-based string transformation via bitmasks and handle offline 2D range count queries using dynamic point-update data structures.

    Math & Bit Manipulationbit-manipulation2d-fenwick-treesweep-lineprefix-sum
  • Math & Bit ManipulationMediumModel answer
    Spot Hidden Differences Between Two Array Routines

    Decide whether two array-processing routines behave identically under 32-bit integer rules, find a smallest counterexample if not, and design tests that expose subtle divergences.

    Math & Bit Manipulationprogram-equivalenceinteger-overflowproperty-based-testingdifferential-testing
  • Math & Bit ManipulationEasyModel answer
    Two Islanders, One Accusation: Which Role Pairs Work?

    One islander accuses the other of always lying. Test all four role pairings and decide which ones are logically possible.

    Math & Bit Manipulationlogicpuzzlecase-analysisknights-and-knaves
  • Math & Bit ManipulationMediumModel answer
    Simulate 2048 Mechanics and Pack Grid into 64-Bit Integer

    Simulate grid sliding and merging rules for the game 2048, and design a bit-packing scheme to compress the 4x4 state into a single 64-bit integer.

    Math & Bit Manipulationbit-manipulationarrayssimulationmatrix
  • Math & Bit ManipulationEasyModel answer
    Circle Point Generation, Strict Monotonic Run, and Histogram Interpolation

    Solve three foundational tasks: uniform random sampling within a disk, tracking the longest strictly increasing contiguous array, and computing bucketed percentiles.

    Math & Bit Manipulationsamplingarraysinterpolationmath
  • Math & Bit ManipulationMediumModel answer
    Cheapest Cart Total with Percent-Off and Buy-X-Get-Y Promotions

    Define pricing rules for percent-off and buy-X-get-Y promotions, then build an algorithm that returns the lowest legal total for a cart, covering stacking, repeats, and rounding.

    Math & Bit Manipulationpricingdiscountsrequirements-clarificationgreedy
  • Math & Bit ManipulationEasyModel answer
    Handling IEEE 754 Floating-Point Limits in JavaScript

    Understand JavaScript numeric edge cases, floating-point precision constraints, and how to safely implement custom checks without built-in helpers.

    Math & Bit Manipulationjavascriptieee-754numeric-precisiontype-coercion
  • Math & Bit ManipulationHardModel answer
    Comprehensive Algorithmic Practice Set: Bitwise, Window, Monotonic Stack & Tree Operations

    A practice collection covering essential algorithms: bit manipulation, two pointers, monotonic stack, dynamic programming, binary search, tree path XORs, and graph re-rooting.

    Math & Bit Manipulationbit-manipulationmonotonic-stacktree-dpdynamic-programming
  • Math & Bit ManipulationHardModel answer
    Numbers with Double Sum-of-Squares Decompositions

    Count unique pairs of non-negative integers whose squares sum to a target value, identifying numbers with exactly two representations up to a limit N.

    Math & Bit Manipulationmath-bitsarraysmath
  • Math & Bit ManipulationEasyModel answer
    Timed Reasoning Quiz: Sequences, Cycles and Grammar Gaps

    Answer three short reasoning items (number sequence, repeating symbols, sentence completion) and explain a time-boxed strategy for a 50-item, 15-minute screen with no wrong-answer penalty.

    Math & Bit Manipulationaptitudepattern-recognitionmodular-arithmetictime-management
  • Math & Bit ManipulationEasyModel answer
    Axial Tilt and Doubling Money: Two Estimation Questions

    Explain the physical cause of hot summers and cold winters, then compute the balance of a $1,000 deposit that earns 100% interest compounded yearly for 20 years.

    Math & Bit Manipulationestimationcompound-interestexponential-growthmental-math
  • 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 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 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 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 ManipulationMediumModel answer
    Bounded Robot Path Under Infinite Command Repeats

    Simulate one pass of a compressed command string, then decide whether infinitely repeating it keeps the robot inside a finite region, even with obstacles.

    Math & Bit Manipulationsimulationcycle-detectiongeometrystate-machine
  • Math & Bit ManipulationHardModel answer
    Do Two Walkers Ever Share the Same Tile?

    Determine if two entities moving on an infinite 2D grid ever occupy the same cell at the same integer time step.

    Math & Bit Manipulationgeometrysimulationinterval-arithmetictwo-pointers
  • Math & Bit ManipulationMediumModel answer
    Four Labeled Boxes, Only One Label Tells the Truth

    Use a complementary pair of quantified statements to pin down which label is false, then read off the forced conclusion.

    Math & Bit Manipulationlogicpropositional-reasoningquantifiersconstraint-satisfaction
  • Math & Bit ManipulationMediumModel answer
    Build a [0,1) Sampler from Fair Coin Flips

    Design an algorithm that uses a fair-bit source to produce a number uniformly distributed on [0,1), and analyze its error and cost.

    Math & Bit Manipulationprobabilityrandomized-algorithmsbit-manipulationfloating-point
  • Math & Bit ManipulationMediumModel answer
    Integer Sequence Rule Inference and Next-Term Prediction

    Design a systematic program that detects the governing rule of an integer sequence and predicts the next k terms, ranked by plausibility.

    Math & Bit Manipulationpattern-recognitionmodel-selectionfinite-differencesrecurrences
  • Math & Bit ManipulationMediumModel answer
    Most Negative 8-bit Value with Exactly Three Set Bits

    Find the smallest two's-complement signed 8-bit integer whose binary representation contains exactly three 1 bits.

    Math & Bit Manipulationbit-manipulationtwo's-complementsigned-integers
  • Math & Bit ManipulationMediumModel answer
    Compute Sum of Divisible Integers Using Inclusion-Exclusion

    Find the total of all positive integers below n divisible by 3, 5, or 7 in constant time using arithmetic series and inclusion-exclusion.

    Math & Bit Manipulationinclusion-exclusionarithmetic-seriesnumber-theory