Intermediate Counting Problems for Coding Interviews
155 intermediate Counting problems from real coding interviews, each with test cases you can run online. By difficulty they split into 0 basic, 155 intermediate and 0 advanced. The companies that ask them most often are Amazon, Google, 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
- Count and Say (Intermediate)
- Count Primes (Intermediate)
- Counting Bits (Intermediate)
- Sort Characters by Frequency (Intermediate)
- Count Good Digit Strings (Intermediate)
- Count Substrings of Ones (Intermediate)
- Minimum Deletions for Unique Frequencies (Intermediate)
- Count Pairs With a Difference (Intermediate)
- Count Subarrays With K Odd Numbers (Intermediate)
- Count Pairs With Sum Below Target (Intermediate)
- Array Frequency Analysis (Intermediate)
- Minimum Coin Count With Limited Inventory (Intermediate)
- Count Palindromic Substrings (Intermediate)
- Count Subarrays With Fixed Bounds (Intermediate)
- Count Subsets With Given XOR (Intermediate)
- Count Numbers With Unique Digits (Intermediate)
- Count Multiples in a Range (Intermediate)
- Count Smaller Values After Each Element (Intermediate)
- Count Complete Components (Intermediate)
- Count Walks With Exact Length (Intermediate)
- Count Good Digit Strings (Intermediate)
- Count Ways to Tile Board (Intermediate)
- Count Perfect Matchings (Intermediate)
- Count Divisible Numbers in Range (Intermediate)
- Count Substrings With Exactly K Distinct (Intermediate)
- Count Ways to Form Target From Columns (Intermediate)
- Count Subarrays With Sum Multiple of K (Intermediate)
- Count Range Frequency Queries (Intermediate)
- Longest Increasing Subsequence Count (Intermediate)
- Count Good Nodes in Binary Tree (Intermediate)
- Count Complete Tree Nodes (Intermediate)
- Count Univalue Subtrees (Intermediate)
- Count Nodes Equal to Subtree Average (Intermediate)
- Count Full Binary Trees (Intermediate)
- Count Same-Label Nodes in Subtrees (Intermediate)
- Strongly Connected Components Count (Intermediate)
- Count Sub Islands (Intermediate)
- Count Paths in a DAG (Intermediate)
- Count Unreachable Pairs (Intermediate)
- Count Vowel Permutations (Intermediate)
- Count Square Submatrices (Intermediate)
- Count Palindromic Partitions (Intermediate)
- Count Ways to Distribute Candies (Intermediate)
- Digit Sum in Range Count (Intermediate)
- Count Number of Texts (Intermediate)
- Count Ways to Build Good Strings (Intermediate)
- Group Shifted Strings Count (Intermediate)
- Maximum Occurrences of a Substring (Intermediate)
- 4Sum Count (Intermediate)
- Frequency Tracker (Intermediate)
- Count Number of Teams (Intermediate)
- Count Collisions on a Road (Intermediate)
- Count Nodes With the Highest Score (Intermediate)
- Count Root-to-Leaf Paths With Distinct Values (Intermediate)
- Count Triangles in a Graph (Intermediate)
- Count Servers That Communicate (Intermediate)
- Count Unguarded Cells (Intermediate)
- Merged Accounts Count (Intermediate)
- Count Subsets With Sum K (Intermediate)
- Count Ways to Group Overlapping Ranges (Intermediate)
- Count Submatrices With All Ones (Intermediate)
- Count Numbers With Non-Decreasing Digits (Intermediate)
- Integer Partitions Count (Intermediate)
- Count Strings With Exactly K Distinct Letters (Intermediate)
- Count Complete Subarrays (Intermediate)
- Count the Number of Fair Pairs (Intermediate)
- Count Number of Bad Pairs (Intermediate)
- Count Homogenous Substrings (Intermediate)
- Count Simplified Fractions (Intermediate)
- Count Subarrays With GCD Equal to K (Intermediate)
- Count Subarrays With LCM Equal to K (Intermediate)
- Count Numbers Coprime to N in a Range (Intermediate)
- Count Anagram Substring Pairs (Intermediate)
- Longest Substring With Vowel Count Divisible by K (Intermediate)
- Count Substrings With More Vowels Than Consonants (Intermediate)
- Count Subarrays Where Maximum Appears at Both Ends (Intermediate)
- Count Pairs With Absolute Difference At Most K (Intermediate)
- Count Subarrays With All Distinct Elements (Intermediate)
- Count Triplets With Sum Less Than Target (Intermediate)
- Count Pairs Whose Sum Is a Power of Two (Intermediate)
Related
Frequently asked questions
How do I get good at counting 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 counting 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.