Validate Parentheses String with Wildcards

Asked atVegapay
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Track lowest and highest possible open counts
  2. 02Update both bounds for each character
  3. 03Reject when the high bound is negative
  4. 04Clamp the low bound at zero
  5. 05Accept only if low is zero at the end

Reference answer

Then expect these follow-ups

  • Why is the feasible range contiguous?

    Tests: correctness reasoning

  • How would you construct one valid interpretation?

    Tests: follow-up reasoning

Hiring now

Vegapay has 17 open roles right now

landed applies to roles like these for you, on each company’s own site, with answers written for the role.

Get 5x interviews10 free auto-applies. No card.
  • Software Development Engineer - Frontend

    Bengaluru

  • Senior Software Engineer - Backend

    Bengaluru

  • Associate Product Director

    Bengaluru

Or practice this question first

Next question