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
Solution54.3%Hard
Math, Recursion· 7 companies
Solution31.6%Hard
Array, Geometry +2· 16 companies
Solution47.3%Hard
Math, Recursion +2· 25 companies
Solution39.9%Hard
Dynamic Programming, Math +1· 6 companies
Solution34.9%Hard
Math, Recursion +1· 24 companies
Solution43.5%Hard
Backtracking, Math +1· 7 companies
296. Best Meeting PointVideoPremium
Solution61.1%Hard
Array, Math +2· 9 companies
335. Self CrossingVideo
Solution36.9%Hard
Array, Geometry +1· 1 company
458. Poor PigsVideo
Solution59.4%Hard
Solution40.2%Hard
Enumeration, Math· 1 company
Solution47.6%Hard
Binary Search, Math· 3 companies
Solution32.2%Hard
Math, String· 8 companies
587. Erect the FenceVideo
Solution53.4%Hard
Array, Geometry +1· 3 companies
660. Remove 9VideoPremium
–57.3%Hard
Math· 1 company
679. 24 GameVideo
Solution59.4%Hard
Array, Backtracking +1· 7 companies
Solution35.4%Hard
Array, Binary Search +4· 3 companies
Solution49.8%Hard
Hash Table, Math +3· 3 companies
772. Basic Calculator IIIVideoPremium
Solution53.2%Hard
Math, Recursion +2· 16 companies
780. Reaching PointsVideo
Solution34.9%Hard
Math· 14 companies
Solution51.9%Hard
Array, Bit Manipulation +2· 2 companies
Solution67.3%Hard
Array, Bit Manipulation +3· 3 companies
Solution43.2%Hard
Enumeration, Math· 7 companies
843. Guess the WordVideo
Solution36.9%Hard
Array, Game Theory +3· 10 companies
Solution37.1%Hard
Binary Search, Math· 3 companies
887. Super Egg DropVideo
Solution30.6%Hard
899. Orderly QueueVideo
Solution67.4%Hard
Math, Sorting +1· 2 companies
Solution40.5%Hard
Enumeration, Math· 1 company
913. Cat and MouseVideo
Solution36.2%Hard
Solution41.9%Hard
Array, Math· 2 companies
Solution47.9%Hard
Math, String· 2 companies
Solution51.9%Hard
Array, Backtracking +5· 2 companies
1067. Digit Count in RangeVideoPremium
Solution46.4%Hard
1088. Confusing Number IIVideoPremium
Solution47.1%Hard
Backtracking, Math· 1 company
Solution49.2%Hard
Array, Greedy +2· 1 company
Solution65.6%Hard
Array, Math +1· 5 companies
1259. Handshakes That Don't CrossVideoPremium
Solution61.1%Hard
Solution33.5%Hard
Array, Backtracking +2· 3 companies
1406. Stone Game IIIVideo
Solution68.0%Hard
Array, Dynamic Programming +2· 2 companies
Showing 1–50 of 182

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.