PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCareers
|Home/Coding & Algorithms/Google

Determine validity after digit-constrained deletions

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in string processing, constrained matching, combinatorial reasoning, and algorithm design with attention to time and space complexity.

  • Medium
  • Google
  • Coding & Algorithms
  • Software Engineer

Determine validity after digit-constrained deletions

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

You're given a string S of length n consisting only of '(' , ')' , and digits '0'–'9'. For every digit at index i with numeric value v: ( 1) you must delete exactly v parentheses that occur at indices strictly less than i; ( 2) a given parenthesis can be deleted at most once across all digits; ( 3) digits themselves are not deleted and should be ignored when checking validity. After choosing deletions for all digits, consider the sequence of remaining parentheses (ignoring digits). Return true if there exists at least one choice of deletions such that the remaining parentheses form a valid parentheses string, otherwise return false. Also describe an efficient algorithm, its time and space complexity, and optionally output one valid witness set of deletions if it exists.

Quick Answer: This question evaluates proficiency in string processing, constrained matching, combinatorial reasoning, and algorithm design with attention to time and space complexity.

Related Interview Questions

  • Compute Turnstile Crossing Times - Google (hard)
  • Simulate In-Place Cellular State Updates - Google (hard)
  • Determine Whether a Word Exists in a Graph - Google (medium)
  • Solve Shortest Paths and Rental Allocation - Google (medium)
  • Solve Two Array Optimization Problems - Google (medium)
Google logo
Google
Aug 8, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
6
0

You're given a string S of length n consisting only of '(' , ')' , and digits '0'–'9'. For every digit at index i with numeric value v: (

  1. you must delete exactly v parentheses that occur at indices strictly less than i; (
  2. a given parenthesis can be deleted at most once across all digits; (
  3. digits themselves are not deleted and should be ignored when checking validity. After choosing deletions for all digits, consider the sequence of remaining parentheses (ignoring digits). Return true if there exists at least one choice of deletions such that the remaining parentheses form a valid parentheses string, otherwise return false. Also describe an efficient algorithm, its time and space complexity, and optionally output one valid witness set of deletions if it exists.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Google•More Software Engineer•Google Software Engineer•Google Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • Careers
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.