Reported August 2024
Commvaultdynamic programming

Count Good Strings

Reported by candidates from Commvault's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Commvault OA. Under 2s to a working solution.
Founder's read

Commvault asked this in August 2024, and it's a classic dynamic programming setup disguised as a counting problem. You're building strings under constraints and need to count how many valid combinations exist. The trap is thinking recursively without memoization, which tanks on larger inputs. StealthCoder will have the DP transition ready if you blank on the state definition during the live assessment.

Pattern and pitfall

This is dynamic programming with state compression. The core insight: define dp[i] as the count of valid strings up to position i, then figure out what makes a string 'good' based on the problem constraints. Most candidates stumble on overlapping subproblems, recalculating the same states repeatedly. The trick is recognizing that you can build bottom-up, where each position depends only on a fixed set of prior positions. If the constraint involves character frequency or forbidden substrings, you may need an extra dimension to track state. StealthCoder handles the DP table initialization and transition logic so you don't lose points to off-by-one errors or missed base cases.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Count Good Strings cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as count different palindromic subsequences. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Commvault's OA.

Commvault reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Good Strings FAQ

What makes a string 'good' in this problem?+

Without the full problem text, the definition likely hinges on character constraints, length limits, or forbidden patterns. During the OA, read the exact rules carefully. Good strings often exclude certain substrings or require balanced/alternating patterns. Nail the definition before coding.

Can I brute force all strings and filter?+

No. If n is even moderately large (n > 20), brute force is exponential and will time out. DP counts valid strings without generating them, which is the whole point.

How do I avoid recalculating the same subproblems?+

Use a DP array (or memoized dict) indexed by position and any state you need to track. If the problem requires tracking the last k characters or a frequency map, include that in your state key.

Is the base case dp[0] = 1 or 0?+

Usually dp[0] = 1, meaning there's one valid empty string or string of length 0. Check the problem constraints and examples to confirm before submitting.

What if the constraint is modular arithmetic?+

If the problem asks for the count modulo a prime (like 10^9 + 7), apply the modulo at every addition step to prevent overflow. Commvault often uses this to keep numbers manageable.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Commvault.

OA at Commvault?
Invisible during screen share
Get it