Gyanthakur / LeetCode_potd

16 stars 34 forks source link

Minimum Add to Make Parentheses String Valid #22

Closed TanishaBansal101 closed 2 weeks ago

TanishaBansal101 commented 2 weeks ago

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.

Gyanthakur commented 2 weeks ago

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.

if you have any other query reach out to me

LinkedIn
WhatsApp