MEDIUMasked at 2 companies

Number of Matching Subsequences

A medium-tier problem at 51% community acceptance, tagged with Array, Hash Table, String. Reported in interviews at Visa and 1 others.

Founder's read

Number of Matching Subsequences shows up in live assessments at Visa and Salesforce, and it's the kind of problem where the brute-force solution times out hard. You're given a string and an array of queries, and you need to count how many query strings are subsequences of the main string. The naive approach, checking each query one by one, will fail on large inputs. The real solution uses dynamic programming or binary search to preprocess the string so each query runs in logarithmic time. If this lands in your OA and you're not immediately sure about the indexing trick, StealthCoder surfaces a working solution in seconds while the proctor sees only your screen.

Companies asking
2
Difficulty
MEDIUM
Acceptance
51%

Companies that ask "Number of Matching Subsequences"

If this hits your live OA

Number of Matching Subsequences 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 engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.

Get StealthCoder
What this means

The trap is thinking you can just iterate through each query and scan the main string linearly for each one. That's O(n * m * k) where n is string length, m is query count, and k is average query length. Instead, precompute a list of indices for each character in the main string, then for each query, binary search those indices to jump forward efficiently. This drops you to O((n + m*k) * log n) and passes comfortably. Another angle is a trie-based DP approach where you track all possible subsequence states. The key insight is that you're not matching the full string, just finding whether a subsequence exists, so you can skip characters freely. Half the candidates nail the problem definition but stumble on the index-tracking logic. StealthCoder hedges that stumble on live assessment day.

Pattern tags

The honest play

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

Number of Matching Subsequences 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 engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Number of Matching Subsequences interview FAQ

Is this problem actually that common in interviews?+

It's been reported by at least two major companies (Visa, Salesforce). Medium difficulty with 50% acceptance means it's aimed at mid-level screening, not trivial but not rare. The subsequence matching pattern shows up often in string problems, so even if the exact problem doesn't appear, the technique transfers.

What's the trick most people miss?+

They code a solution that works on small inputs but times out on large ones. The trick is preprocessing: build a map of character indices in the main string once, then use binary search per query. Without this, you're rechecking the same substring repeatedly. The jump-ahead logic is the actual hard part.

Should I use binary search or dynamic programming?+

Binary search with index preprocessing is faster and more intuitive for most candidates. You build a dictionary where each character maps to a sorted list of positions, then for each query character, binary search to find the next valid position. DP approaches work too but are harder to code correctly under time pressure.

How does this relate to the other string topics listed?+

The topics (Array, Hash Table, String, Binary Search, DP, Trie, Sorting) all touch this problem. You use hash tables for the index map, binary search for the jump logic, arrays for storage, and sorting happens implicitly in your preprocessing. It's a high-concept problem that touches many fundamentals.

Will I see this at other companies if I study it?+

Maybe not the exact problem, but subsequence matching appears across tech. The index-jumping and binary search pattern on preprocessed data is a reusable technique. Visa and Salesforce asking it suggests it's part of mid-level screening rotations, so it's worth knowing cold.

Want the actual problem statement? View "Number of Matching Subsequences" 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.