All Patterns

Math & Number Theory

Solve problems with number properties, digit manipulation, and arithmetic identities instead of brute-force iteration.

When to use

  • Digit manipulation (reverse, count, sum)
  • Primes, GCD/LCM, divisibility
  • Number base conversion
  • A closed-form or formula exists

When NOT to use

  • The data structure matters more than the arithmetic
  • Overflow makes direct computation unsafe

Common traps

  • Integer overflow on intermediate values
  • Negative numbers and sign handling
  • Off-by-one in modulo or digit counts

Key Invariant

Look for a numeric property or identity that replaces iteration with arithmetic

Problems (11)

#8Palindrome Number
easyFREE
#57Power of Two
easy
#232Happy Number
easy
#233Excel Sheet Column Number
easy
#236GCD and LCM
easy
#7Reverse Integer
mediumFREE
#203Pow(x, n)
medium
#223Multiply Strings
medium
#234Factorial Trailing Zeroes
medium
#235Integer to Roman
medium
#237Sieve of Eratosthenes
medium