Tap here to switch tabs
Problem
Submissions

Problem: Valid Parenthesis String

med
30 min
Try to solve the Valid Parenthesis String problem.

Statement

Given a string s containing only the characters '(', ')', and '*', determine whether s is valid and return true if so.

A string is considered valid if it satisfies all of the following rules:

  • Every '(' must have a corresponding ')'.

  • Every ')' must have a corresponding '('.

  • Each '(' must appear before its corresponding ')'.

  • The '*' character is flexible and may be interpreted as a '(', a ')', or an empty string "".

Constraints:

  • 11 \leq s.length 102\leq 10^2

  • s[i] is either '(', ')', or '*'

Unlock AI-Powered LearningUpgrade to smarter learning with instant explanations of Ask Agent, Personalized Interview Prep, Real-World Projects, 3 AI Mock Interviews per month, and Personalized Paths
Tap here to switch tabs
Problem
Submissions

Problem: Valid Parenthesis String

med
30 min
Try to solve the Valid Parenthesis String problem.

Statement

Given a string s containing only the characters '(', ')', and '*', determine whether s is valid and return true if so.

A string is considered valid if it satisfies all of the following rules:

  • Every '(' must have a corresponding ')'.

  • Every ')' must have a corresponding '('.

  • Each '(' must appear before its corresponding ')'.

  • The '*' character is flexible and may be interpreted as a '(', a ')', or an empty string "".

Constraints:

  • 11 \leq s.length 102\leq 10^2

  • s[i] is either '(', ')', or '*'

Unlock AI-Powered LearningUpgrade to smarter learning with instant explanations of Ask Agent, Personalized Interview Prep, Real-World Projects, 3 AI Mock Interviews per month, and Personalized Paths