Basic Math Problems for Coding Interviews
213 basic Math problems from real coding interviews, each with test cases you can run online. By difficulty they split into 213 basic, 0 intermediate and 0 advanced. The companies that ask them most often are Google, Amazon, Microsoft, Meta.
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)
- Power of Two (Basic)
- Sum of Digits (Basic)
- Tribonacci Number (Basic)
- Greatest Common Divisor of an Array (Basic)
- Largest Odd Prefix (Basic)
- Power of Three (Basic)
- Power of Four (Basic)
- Plus One (Basic)
- Integer Square Root (Basic)
- Repeated Digit Sum (Basic)
- Ugly Number (Basic)
- Nim Game (Basic)
- Maximum Water Bottles (Basic)
- Maximum 69 Number (Basic)
- 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)
- Largest Triple of Equal Digits (Basic)
- Count Numbers With Even Digits (Basic)
- Chinese Remainder Solver (Basic)
- Count Trailing Zeros in Factorial (Basic)
- Find All Shortest Transformation Paths (Basic)
- Boolean Parenthesization Count (Basic)
- Insert GCDs Between Adjacent Nodes (Basic)
- Binary Linked List to Integer (Basic)
- Plus One Linked List (Basic)
- Sum of Root-to-Leaf Binary Numbers (Basic)
- Integer Break (Basic)
- Number of Ways to Build House Plots (Basic)
- Take Gifts From the Richest Pile (Basic)
- Perfect Number (Basic)
- Self Dividing Numbers (Basic)
- Convert to Base 7 (Basic)
- Prime Arrangements (Basic)
- Letter Case Permutation (Basic)
- Add to Array-Form of Integer (Basic)
- Second Largest Digit in a String (Basic)
- Zigzag Linked List (Basic)
- Delete Nodes at Prime Positions (Basic)
- Friends Pairing Problem (Basic)
- Divisor Game (Basic)
- Derangements Count (Basic)
- License Key Formatting (Basic)
- Shortest Completing Word (Basic)
- Sorting the Sentence (Basic)
- Thousand Separator (Basic)
- Word Equals Summation of Two Words (Basic)
- Remove Digit to Maximize Result (Basic)
- Day of the Week (Basic)
- Latest Time by Replacing Hidden Digits (Basic)
- Largest Time for Given Digits (Basic)
- Number of Valid Clock Times (Basic)
- Strong Password Checker II (Basic)
- Distribute Candies to People (Basic)
- Matrix Diagonal Sum (Basic)
- Distinct Integers After Reverse Operations (Basic)
- Largest Number After Parity Swaps (Basic)
- Minimum Deci-Binary Numbers (Basic)
- Add Digits (Basic)
- Prime Number of Set Bits (Basic)
- Armstrong Number (Basic)
- Construct the Rectangle (Basic)
- Number of Common Factors (Basic)
- Three Divisors (Basic)
- Digits That Divide a Number (Basic)
- Alternating Digit Sum (Basic)
- Count Integers With Even Digit Sum (Basic)
- Pass the Pillow (Basic)
- Count Squares of Primes in Range (Basic)
- Highest Power of a Prime Dividing a Product (Basic)
- Count Abundant Numbers up to N (Basic)
- Stair Climbing With Steps One Two or Three (Basic)
- Count Binary Strings Without Consecutive Ones (Basic)
- Collatz Steps Count (Basic)
- Disk Moved at Step of Hanoi (Basic)
- Power of Two Moves Game Winner (Basic)
- Bounded Take Game Winner (Basic)
Related
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.