Math Problems for Coding Interviews
717 Math problems from real coding interviews, each with test cases you can run online. By difficulty they split into 213 basic, 316 intermediate and 188 advanced. The companies that ask them most often are Google, Amazon, Meta, Microsoft.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Valid Palindrome (Basic)
- Decode Ways (Intermediate)
- Power of Two (Basic)
- Sum of Digits (Basic)
- Happy Number (Intermediate)
- Tribonacci Number (Basic)
- Greatest Common Divisor of an Array (Basic)
- Largest Odd Prefix (Basic)
- Count and Say (Intermediate)
- Integer to Roman (Intermediate)
- Power of Three (Basic)
- Count Primes (Intermediate)
- Power of Four (Basic)
- Coin Change Ways (Advanced)
- Target Sum (Advanced)
- Reverse Integer (Intermediate)
- Sum of Two Squares (Intermediate)
- Plus One (Basic)
- Largest Number From Digits (Advanced)
- Integer Square Root (Basic)
- Repeated Digit Sum (Basic)
- Ugly Number (Basic)
- Nim Game (Basic)
- Maximum Water Bottles (Basic)
- Greatest Common Divisor of Strings (Intermediate)
- Maximum 69 Number (Basic)
- Sum of Subarray Minimums (Advanced)
- Count Good Digit Strings (Intermediate)
- Count Substrings of Ones (Intermediate)
- Product Minus Sum of Digits (Basic)
- Sum of Multiples of 3, 5 and 7 (Basic)
- Count Odd Numbers in a Range (Basic)
- Number of Steps to Reduce to Zero (Basic)
- Smallest Even Multiple (Basic)
- Minimum Flips to Alternate Digits (Intermediate)
- Largest Triple of Equal Digits (Basic)
- Maximum Swap of Digits (Intermediate)
- Dice Rolls to Reach a Target (Advanced)
- Remove K Digits to Get the Smallest Number (Intermediate)
- Count Numbers With Even Digits (Basic)
- Modular Exponentiation (Advanced)
- Prime Factorization (Intermediate)
- Chinese Remainder Solver (Basic)
- Minimum Knight Moves (Intermediate)
- Count Numbers With Unique Digits (Intermediate)
- Count Multiples in a Range (Intermediate)
- Smallest Number From Pattern (Intermediate)
- Count Shortest Paths (Advanced)
- Count Walks With Exact Length (Intermediate)
- Coin Change Ways (Intermediate)
- Count Subsequence Occurrences (Advanced)
- Count Good Digit Strings (Intermediate)
- Number of Digit One (Advanced)
- Count Trailing Zeros in Factorial (Basic)
- Unique Paths With Obstacles (Intermediate)
- Sum of Subarray Minimums (Advanced)
- Count Ways to Tile Board (Intermediate)
- Prime Factorization Queries (Intermediate)
- Median of Sliding Windows (Intermediate)
- Find All Shortest Transformation Paths (Basic)
- Count Perfect Matchings (Intermediate)
- Count Divisible Numbers in Range (Intermediate)
- Root-to-Leaf Number Sum (Intermediate)
- Count Ways to Form Target From Columns (Intermediate)
- Median of Row-Wise Sorted Matrix (Intermediate)
- Minimum Number of Perfect Squares (Intermediate)
- Longest Increasing Subsequence Count (Intermediate)
- Egg Drop Minimum Attempts (Intermediate)
- Decode Ways With Wildcards (Intermediate)
- Cryptarithm Solver (Intermediate)
- SAT Assignment (Intermediate)
- Boolean Parenthesization Count (Basic)
- Polynomial Multiplication (Advanced)
- Linear Recurrence Queries (Intermediate)
- Add Two Numbers as Linked Lists (Intermediate)
- Double a Number Stored in a Linked List (Intermediate)
- Pseudo-Palindromic Root-to-Leaf Paths (Intermediate)
- Add Two Numbers Forward Order (Intermediate)
- Reverse Nodes in Even Length Groups (Intermediate)
- Insert GCDs Between Adjacent Nodes (Basic)
Related
- Basic Math problems
- Intermediate Math problems
- Advanced Math problems
- Practice coding problems online
- All interview guides
Frequently asked questions
How do I get good at math problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run math problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.