Minimum Add to Make Parentheses String Valid #22
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Template
Description
A parentheses string is considered valid if it meets one of the following conditions:
It is an empty string.
It can be written as a concatenation of two valid strings, i.e., AB, where both A and B are valid.
It can be written as (A), where A is a valid string.
You are given a parentheses string s. In one move, you can insert either an opening parenthesis '(' or a closing parenthesis ')' at any position in the string. Your task is to determine the minimum number of moves (insertions) required to make the string valid.
Fixes: #1
Type of Change
-[x] Question Added
-[x] Solution Added
-[x] Bug fix
-[x] New feature
-[x] Documentation update
-[ ] Other (please specify):
Checklist
-[x] I have performed a self-review of my code.
-[x] I have commented my code, particularly in hard-to-understand areas.
-[x] I have made corresponding changes to the documentation (if applicable).
-[x] My changes generate no new warnings.
-[x] I have added tests to cover my changes (if applicable).
-[x] All new and existing tests pass.