Talentd
FleetCode
Make and follow sheets.Sign in

Math Problems (691)

Problems tagged with Math. Start with the easy ones, then move to medium and hard.

173 Easy331 Medium187 Hard

Learn these first

1
Prefix Sum

Useful when math problems involve cumulative calculations over arrays or ranges, enabling efficient O(1) range queries after preprocessing.

2
Combinatorics

Essential for solving counting problems involving permutations, combinations, factorials, and arrangement calculations in interview questions.

3
Number Theory

Provides the foundation for many math problems such as primes, divisibility, modular arithmetic, GCD, and LCM. These concepts frequently appear in coding interview math questions.

4
Bit Manipulation

Many math optimizations rely on bitwise operations for fast calculations such as power-of-two checks, parity, and binary arithmetic tricks.

5
Probability and Statistics

Helps with interview problems that involve expected values, probability distributions, and randomized algorithms.

TitleSolutionAcceptDifficultyTopics
Solution59.7%Medium
Array, Dynamic Programming +3· 6 companies
Solution46.9%Medium
Hash Table, Math +2· 1 company
Solution31.3%Medium
Array, Hash Table +2· 9 companies
Solution49.0%Medium
Array, Binary Search +3· 26 companies
Solution73.9%Medium
Math, Simulation +1· 3 companies
Solution62.7%Medium
Array, Math +2· 9 companies
Solution64.0%Medium
Array, Dynamic Programming +1· 1 company
Solution35.2%Medium
Math, String +1· 11 companies
573. Squirrel SimulationVideoPremium
Solution57.1%Medium
Array, Math· 1 company
Solution66.6%Medium
Math, Simulation +1· 5 companies
593. Valid SquareVideo
Solution45.5%Medium
Geometry, Math· 3 companies
625. Minimum FactorizationVideoPremium
Solution34.2%Medium
Greedy, Math· 1 company
Solution37.0%Medium
Binary Search, Math +1· 6 companies
Solution41.9%Medium
Solution46.7%Medium
Math, Simulation +1· 2 companies
650. 2 Keys KeyboardVideo
Solution59.6%Medium
Dynamic Programming, Math· 7 companies
651. 4 Keys KeyboardVideoPremium
Solution56.5%Medium
Dynamic Programming, Math· 2 companies
Solution61.1%Medium
Array, Math· 2 companies
670. Maximum SwapVideo
Solution51.6%Medium
Greedy, Math· 9 companies
Solution50.1%Medium
Greedy, Math· 3 companies
Solution67.8%Medium
Array, Dynamic Programming +2· 1 company
754. Reach a NumberVideo
Solution45.5%Medium
Binary Search, Math· 8 companies
Solution42.9%Medium
Array, Math· 1 company
Solution48.7%Medium
Bit Manipulation, Math +1· 7 companies
Solution58.0%Medium
Array, Greedy +2· 8 companies
788. Rotated DigitsVideo
Solution63.9%Medium
Dynamic Programming, Math· 6 companies
Solution64.2%Medium
Array, Math· 2 companies
808. Soup ServingsVideo
Solution59.7%Medium
Dynamic Programming, Math +1· 3 companies
837. New 21 GameVideo
Solution52.0%Medium
Dynamic Programming, Math +2· 5 companies
Solution55.1%Medium
Array, Hash Table +2· 5 companies
Solution62.3%Medium
Geometry, Math +1· 3 companies
Solution28.6%Medium
Math, Number Theory· 3 companies
Solution66.0%Medium
Counting, Enumeration +3· 5 companies
877. Stone GameVideo
Solution77.0%Medium
Array, Dynamic Programming +2· 4 companies
Solution38.4%Medium
Array, Greedy +2· 3 companies
932. Beautiful ArrayVideo
Solution70.7%Medium
Array, Divide and Conquer +1· 4 companies
Solution55.4%Medium
Array, Geometry +3· 8 companies
Solution39.0%Medium
Array, Bit Manipulation +2· 1 company
Solution55.9%Medium
Array, Geometry +1· 2 companies
Solution69.4%Medium
Array, Divide and Conquer +5· 17 companies
Solution56.6%Medium
Greedy, Math· 5 companies
1006. Clumsy FactorialVideo
Solution61.8%Medium
Math, Simulation +1· 4 companies
Solution54.4%Medium
Hash Table, Math· 6 companies
Solution63.6%Medium
Math· 4 companies
Solution52.8%Medium
Brainteaser, Math· 1 company
Solution59.4%Medium
Array, Math +2· 1 company
Solution56.6%Medium
Math, Simulation +1· 11 companies
Showing 51–100 of 331

More about Math

Math is a fundamental topic in data structures and algorithms that focuses on solving problems using mathematical reasoning, formulas, and number properties. In coding interviews, math-based questions often require efficient computation, pattern recognition, and clever optimizations rather than brute-force solutions. These problems may involve arithmetic manipulation, modular arithmetic, prime numbers, combinatorics, or probability.

Top tech companies frequently include math problems because they test logical thinking, problem decomposition, and optimization skills. Many classic interview questions—such as counting permutations, detecting number patterns, or calculating large values efficiently—require mathematical insights. Instead of iterating through every possibility, a strong math approach can reduce time complexity dramatically.

In practice, math problems in DSA often combine with other algorithmic techniques. For example, bit-level arithmetic frequently appears in Bit Manipulation problems, while counting combinations relies heavily on Combinatorics. Problems involving prime numbers, divisibility, or greatest common divisors connect directly with Number Theory. Sometimes, mathematical observations also optimize array-based computations when paired with techniques like Prefix Sum or greedy reasoning from Greedy algorithms.

Common patterns in math DSA problems include:

  • Using modular arithmetic to prevent integer overflow
  • Recognizing arithmetic or geometric patterns in sequences
  • Applying formulas for combinations, permutations, or factorials
  • Working with greatest common divisors (GCD) and least common multiples (LCM)
  • Optimizing calculations using mathematical identities

You should consider mathematical techniques when a problem involves large numeric constraints, counting possibilities, repeated operations, or pattern-based sequences. Instead of simulating every step, a mathematical formula or observation can often transform an O(n²) solution into O(n) or even O(1).

FleetCode provides designed to help you master these patterns, from beginner-level arithmetic tricks to advanced interview challenges. By practicing consistently, you'll develop the ability to quickly identify hidden mathematical structures and solve coding interview problems efficiently.

Math: common questions

What is the best way to learn Math for DSA?

Start by understanding core concepts like modular arithmetic, GCD/LCM, and prime numbers. Then practice progressively harder problems that combine math with arrays, bit manipulation, or greedy techniques. Consistent practice and recognizing patterns are key to mastering math-based interview questions.

Is Math important for FAANG coding interviews?

Yes, math is an important supporting skill for FAANG interviews. While pure math problems are less common than arrays or graphs, mathematical reasoning often appears inside optimization problems, combinatorics questions, and bit manipulation challenges.

What are common patterns in Math DSA problems?

Common patterns include modular arithmetic, fast exponentiation, factorial and combination formulas, digit manipulation, and mathematical pattern recognition. Many solutions also rely on reducing brute-force computations using formulas or number properties.

Are Math problems harder than other DSA topics?

Math problems can feel harder because they require insight rather than a standard template. However, once you learn common tricks—like modular arithmetic or combinatorics formulas—they often become faster to solve than many graph or dynamic programming problems.

What are the best Math problems for coding interviews?

The best math interview problems focus on patterns such as modular arithmetic, GCD/LCM, prime factorization, and combinatorics. Interviewers often ask problems involving number patterns, fast exponentiation, or counting arrangements.

How many Math problems should I solve for coding interviews?

This range typically exposes you to modular arithmetic, counting tricks, and pattern recognition frequently used in interviews.