Math / Number Theory
Math problems lean on number theory, combinatorics, and arithmetic insight — GCDs, primes, modular arithmetic, overflow — rather than a data structure. The win usually comes from a formula or property that replaces a loop.
10 LeetCode problems solved with the Math / Number Theory pattern. Practice them with spaced repetition so the pattern sticks.
- Add BinaryEASY · O(max(m, n))
- Excel Sheet Column TitleEASY · O(log n)
- Factorial Trailing ZeroesMEDIUM · O(log n)
- Greatest Common Divisor of StringsEASY · O(n + m)
- Integer to RomanMEDIUM · O(1)
- Multiply StringsMEDIUM · O(m * n)
- Palindrome NumberEASY · O(log10(x))
- Plus OneEASY · O(n)
- Reverse IntegerMEDIUM · O(log x)
- Roman to IntegerEASY · O(n)
See the full solution
The complete approach, reference solutions in 5 languages, and a step-by-step visualization — then add this problem to your spaced-repetition schedule.
Start free →