MEDIUMasked at 1 company

Count Substrings Without Repeating Character

A medium-tier problem at 76% community acceptance, tagged with Hash Table, String, Sliding Window. Reported in interviews at Yandex and 0 others.

Founder's read

You're given a string and need to count substrings where every character appears exactly once. Yandex has asked this. The acceptance rate sits at 76%, which sounds high until you realize most people brute-force it and get TLE on the larger test cases. The trick isn't about finding valid substrings, it's about doing it in linear time without rechecking the same window twice. This is a classic sliding window problem that looks easier than it is.

Companies asking
1
Difficulty
MEDIUM
Acceptance
76%

Companies that ask "Count Substrings Without Repeating Character"

If this hits your live OA

Count Substrings Without Repeating Character is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.

Get StealthCoder
What this means

The naive approach checks every substring and scans for duplicates each time, which is O(n^3) or worse. The pattern that works is a two-pointer sliding window with a hash table tracking character positions. Expand the right pointer, add characters, and when you hit a duplicate, shrink from the left until the duplicate is gone. At each step, every character added contributes a certain number of valid substrings ending at that position. The win is that you only pass through the string twice. Most candidates miss the math of how many substrings each position contributes and end up either double-counting or rebuilding the character set from scratch on every contraction. If you blank on the contribution formula during the assessment, StealthCoder reads the problem, applies the pattern, and surfaces a working solution in seconds while the proctor sees nothing.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Count Substrings Without Repeating Character recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Substrings Without Repeating Character interview FAQ

Is this actually asked at interview, or just in practice?+

Yandex has reported it. At 76% acceptance, it's not a rarity, though not top-tier frequent. It's the kind of problem that shows up when a company wants to test whether you can optimize a brute-force idea into linear time, so it's a real screen question.

What's the key insight I'm missing if I get TLE?+

You're likely checking each substring individually or rebuilding state inside loops. Sliding window with a hash table means you move pointers, not restart scans. Track character positions, not just presence. When you encounter a duplicate, jump the left pointer past it in one move, not incrementally.

How does this relate to other string problems I should know?+

Longest Substring Without Repeating Characters is the closest relative, but this one asks for count, not length. The sliding window template is identical. Hash Table and Sliding Window are the core topics here, and that pattern applies to a lot of frequency-based substring problems.

Will I get partial credit if my solution is slow?+

Depends on the platform and their test suite. A brute-force O(n^2) or O(n^3) solution may pass small cases but fail larger ones silently or hit time limits. You won't know until the verdict. Optimal sliding window is safe and runs in under 100ms on standard inputs.

How long should this take me to code in an interview?+

If you know the sliding window pattern, 10 to 15 minutes from problem read to working code. If you don't, you're at risk of defaulting to brute-force and running out of time debugging. That's where having a fallback matters.

Want the actual problem statement? View "Count Substrings Without Repeating Character" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.