Question bank › Strings
Dsa Strings Easy

Substring Frequency Counter

Create a program that counts how many times a given substring appears in a string. The count should be case-sensitive and overlap should not be counted. Input Format: - The first line contains the main string. - The second line contains the substring to search for. Output Format: - A single integer that represents the number of occurrences of the substring. Example: Input: banana ana Output: 1

Key concepts

stringssearchingcounting

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.