Wildcard Multi-Delimiter Validation
Reported by candidates from Tennr's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Tennr reported this one in August 2025, and it looks like a bracket problem until you read the wildcard line. Then it's a different animal. You have (), <>, and a symmetric || pair, plus a * that can be an open paren, a close paren, or nothing. If your OA lands in the next day or two, know what this really reduces to: Valid Parenthesis String with extra bracket types and a bar that toggles. Length caps at 80, so you have room for a clean search instead of a clever trick. StealthCoder sits invisible on your screen as a safety net if you blank mid-assessment.
The problem
Given a string s containing (, ), <, >, |, and *, return whether it can form a valid, properly nested delimiter string. The matching pairs are (), <>, and ||. Each * may independently be (, ), or the empty string. A single | can serve as the opening or closing bar according to its matching partner. Function isValidDelimiters(s: String) → boolean Examples Example 1 s = "<(*)>" return = true Use the wildcard as the empty string; the remaining delimiters are nested. Example 2 s = "<|*)|>" return = true Use the wildcard as an opening parenthesis, producing <|()|>. Example 3 s = "<(|>)" return = false The delimiters cross instead of nesting. Constraints 0 <= s.length <= 80. s contains only (, ), <, >, |, and *.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Here's the reduction. Only * is ambiguous, and it only becomes a paren, never an angle bracket or bar. So <, >, and | are rigid and force strict nesting around them. Use an interval DP on s[i..j] or memoized recursion carrying a stack state. Interval DP: valid(i,j) is true if the empty range is valid, or s[i] can open and match some s[k] with valid(i+1,k-1) and valid(k+1,j). Matching rules: ( pairs with ) where either side can be a *, < pairs with >, and | pairs with |. A * can also be skipped as empty. The pitfall is the bar. Treating | as always opening breaks Example 2. A | closes if the top of the stack is | and opens otherwise, and the DP handles that for free. Don't use the greedy low/high counter from the single-paren version, since mixed types break it. With n at 80, O(n^3) is fine. If you freeze on the live OA, StealthCoder is the hedge.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Wildcard Multi-Delimiter Validation 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Tennr's OA.
Tennr reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Wildcard Multi-Delimiter Validation FAQ
What's the trick in Wildcard Multi-Delimiter Validation?+
Only * is flexible, and it can only act as a parenthesis or vanish. Angle brackets and bars are rigid. That makes interval DP or memoized recursion the clean approach: match the first character with a partner at some index and recurse on the inside and the rest.
How do I handle the | character?+
It's its own partner. When you try to match s[i] with s[k], allow | with | as a valid pair. In a stack approach, if the top is | then | closes it, otherwise it opens. In interval DP the pairing rule covers this without special state.
Can I use the greedy min/max open-count trick?+
Not safely. That works for a single bracket type with *. Here crossing like <(|>) must be rejected, and counts alone can't see ordering across types. You need structure, either a DP over intervals or a stack with backtracking on each *.
What's the complexity I should aim for?+
Length is at most 80, so O(n^3) interval DP is fine. Memoized recursion on (start, end) gives the same bound. Brute-forcing three choices per * is 3^k and can blow up with many wildcards, so memoize.
How do I prepare for this in 48 hours?+
Solve Valid Parenthesis String both ways, greedy and DP. Then write the interval DP version with three pair types and test the three given examples plus the empty string. Empty input should return true. Check a few crossing cases like <(|>) by hand.