Skip to content

Counting Problems
and How to Spot Them

CodeStory tags 91 problems as Counting, and 53 of them are Medium. Count first, reason second, then solve the ten most asked.

Free signup brings 100 AI credits now and 100 more every month.

How the Counting Pattern Works

CodeStory covers the tell, the counting mechanism and the double count mistake.

Spot the tell. Your answer is how many, and the items repeat. Open CodeStory's Hash Table guide for the map behind most counting.

Learn the mechanism. Count first, reason second. Frequency maps and fixed arrays of counts reduce most of these problems to arithmetic on the counts, instead of another walk over the data. Practise maps in CodeStory's hash table problems and array problems.

Avoid the mistake. Counting pairs twice inflates your answer. If order does not matter, divide by two or count forward only. Strings hide counts too, so try CodeStory's string problems.

Most Asked Counting Problems

More companies set the problems at the top of this list.

  1. Number of Divisible SubstringsMedium4 companies
  2. Rank Teams by VotesMedium4 companies
  3. Largest Palindromic NumberMedium3 companies
  4. Maximum Number of Balls in a BoxEasy2 companies
  5. Construct String With Repeat LimitMedium2 companies
  6. Count Elements With Maximum FrequencyEasy2 companies
  7. Check If Array Pairs Are Divisible by kMedium2 companies
  8. Find Players With Zero or One LossesMedium2 companies
  9. Longest Harmonious SubsequenceEasy2 companies
  10. Maximum Number of Pairs in ArrayEasy1 company

Study, Compare and Solve Counting Problems

Follow CodeStory's order to make counting stick.

Counting Problems FAQs

Start free with no card, or ask a mentor on a free call.

Start Practising Counting
How do I know a problem is a Counting problem?

CodeStory looks for two signs. Your answer is how many, and the items repeat.

How many Counting problems should I solve?

CodeStory advises ten to fifteen across the levels, which is enough to stop needing the hint. CodeStory shows all 91 tagged problems, split 32 Easy, 53 Medium and 6 Hard, so start with Easy and work up.

Which mistake costs the most in Counting problems?

Counting pairs twice costs the most. Divide by two when order does not matter, or count forward only.

What data structure suits Counting problems?

Frequency maps and fixed arrays of counts suit them, because they reduce the problem to arithmetic on the counts.

Is practising by pattern better than a problem sheet?

Yes. Sheets hand you problems, while CodeStory's patterns hand you the link between them, and that link carries over to unseen problems. CodeStory files every problem under its pattern.

Which Counting problems do companies ask most?

Number of Divisible Substrings and Rank Teams by Votes lead, both asked at 4 companies in CodeStory's catalogue. Largest Palindromic Number follows at 3 companies.

Is Counting practice free to start?

Yes. You start with no card, receive 100 AI credits at signup and get 100 more every month.

Want Help With Counting? Get a Free Callback

Name your dream role to CodeStory, and a mentor draws up your plan.

  1. 1CodeStory grades your level, from newcomer to interview ready.
  2. 2CodeStory walks you through online and campus batches, with timings that fit your calendar.
  3. 3You decide. No pressure, no payment on the call.

Get a Free Callback

I am a
I want to learn

CodeStory dials your number only for this callback.