Pattern

Math and arithmetic reasoning

Solve with a numeric property or a counting argument, not a data-structure trick — digit rules, modular arithmetic, exponent halving.

What it is

Questions filed under "math" don't share one algorithm; they share the fact that the fast solution comes from a numeric or combinatorial insight rather than from choosing the right data structure. That insight might be a digit-by-digit simulation rule (how carries propagate in addition), a modular-arithmetic identity (when a difference is divisible by k), a halving trick that turns a linear amount of work into a logarithmic amount (repeated squaring), or a counting argument that finds a lower bound the schedule can't beat. What they have in common is that once you see the underlying number fact, the code is short — the difficulty is entirely in spotting the fact.

When it applies

Tells in the problem

The classic mistake

The mistake interviewers report most is reaching for simulation (looping n times, walking every unit of time, generating every subarray) when a closed-form or logarithmic shortcut exists, and only realizing the approach is too slow once the stated bounds (n up to 2^31, arrays of hundreds of thousands of elements) are taken seriously. This happens because simulation is always "obviously correct," so it's tempting to start there and hope it's fast enough — but math-pattern questions are specifically chosen because the naive simulation's complexity doesn't survive the given constraints. The habit that catches this: before coding, multiply out the brute-force complexity against the stated bounds and say the number out loud ("that's on the order of two billion multiplications") — if it sounds too slow, that's the signal to look for the underlying numeric identity instead.

Questions to start with

All 4 math and arithmetic reasoning questions

Problem statement, examples and hints are free on every page; the worked approach, solution and tests are in the company guides.

Free starter pack

13 must-tier questions with full solutions

Sign in with an email — no purchase — and read them in the full reader.

No password, no spam. One sign-in email; you can read the pack in the full reader.