Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Valid Parenthesis String

Medium
greedystringdynamic-programming

A string contains (, ), and *, where each * can act as (, ), or an empty string. Return true if the string can be made a valid parenthesis sequence.

Input: one line, the string. Output: true or false.

Example 1
Input:
()
Output:
true
Example 2
Input:
(*)
Output:
true
Example 3
Input:
(*))
Output:
true

Constraints

  • 1 ≤ s.length ≤ 100
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.