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
Solution61.0%Easy
Math· 31 companies
Solution67.0%Easy
Hash Table, Math +1· 36 companies
66. Plus OneVideo
Solution50.3%Easy
Array, Math· 13 companies
67. Add BinaryVideo
Solution58.4%Easy
Bit Manipulation, Math +2· 17 companies
69. Sqrt(x)Video
Solution42.2%Easy
Binary Search, Math· 17 companies
Solution54.0%Easy
Dynamic Programming, Math +1· 37 companies
Solution47.9%Easy
Math, String· 10 companies
Solution68.6%Easy
Math, String· 9 companies
202. Happy NumberVideo
Solution60.0%Easy
Hash Table, Math +1· 27 companies
231. Power of TwoVideo
Solution50.5%Easy
Bit Manipulation, Math +1· 11 companies
258. Add DigitsVideo
Solution69.3%Easy
Math, Number Theory +1· 10 companies
263. Ugly NumberVideo
Solution43.9%Easy
Math· 8 companies
268. Missing NumberVideo
Solution72.4%Easy
Array, Binary Search +4· 19 companies
292. Nim GameVideo
Solution60.6%Easy
Brainteaser, Game Theory +1· 6 companies
326. Power of ThreeVideo
Solution51.4%Easy
Math, Recursion· 6 companies
342. Power of FourVideo
Solution52.5%Easy
Bit Manipulation, Math +1· 8 companies
Solution44.8%Easy
Binary Search, Math· 8 companies
412. Fizz BuzzVideo
Solution75.9%Easy
Math, Simulation +1· 18 companies
415. Add StringsVideo
Solution52.1%Easy
Math, Simulation +1· 14 companies
441. Arranging CoinsVideo
Solution48.7%Easy
Binary Search, Math· 6 companies
Solution65.2%Easy
Math· 2 companies
504. Base 7Video
Solution55.3%Easy
Math· 4 companies
507. Perfect NumberVideo
Solution50.6%Easy
Math· 8 companies
Solution74.6%Easy
Dynamic Programming, Math +2· 16 companies
Solution59.1%Easy
Array, Math· 3 companies
Solution48.0%Easy
Array, Math +1· 15 companies
Solution81.3%Easy
Math· 5 companies
800. Similar RGB ColorVideoPremium
Solution68.6%Easy
Enumeration, Math +1· 1 company
Solution72.1%Easy
Array, Geometry +1· 3 companies
Solution53.0%Easy
Geometry, Math· 4 companies
Solution76.9%Easy
Array, Geometry +2· 1 company
Solution71.2%Easy
Array, Geometry +2· 1 company
Solution74.0%Easy
Array, Math· 3 companies
Solution30.4%Easy
Array, Counting +3· 2 companies
Solution62.1%Easy
Array, Greedy +2· 5 companies
Solution45.6%Easy
Array, Math· 4 companies
1025. Divisor GameVideo
Solution72.3%Easy
Solution74.6%Easy
Array, Geometry +3· 1 company
1037. Valid BoomerangVideo
Solution40.5%Easy
Array, Geometry +1· 2 companies
1056. Confusing NumberVideoPremium
Solution49.8%Easy
Math· 1 company
Solution54.1%Easy
Math, String· 7 companies
Solution76.6%Easy
Array, Math· 1 company
1118. Number of Days in a MonthVideoPremium
Solution59.4%Easy
Math· 1 company
1134. Armstrong NumberVideoPremium
Solution77.8%Easy
Math· 1 company
Solution63.2%Easy
Dynamic Programming, Math +1· 7 companies
1154. Day of the YearVideo
Solution50.3%Easy
Math, String· 3 companies
Solution63.3%Easy
Math· 1 company
Showing 1–50 of 173

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.