Balanced Parentheses – AlgoBox by dietpepsi
Given a string s of parentheses, return the minimum number of parentheses that need to be inserted to make it well formed.
A well formed (balanced) string of parentheses is defined by the following rules:
1. The empty string is well formed.
2. if s is well formed, then '('+s+')' is also well formed.
3. if s and t are well formed, then their concatenation s+t is also well formed.
Read full article from Balanced Parentheses – AlgoBox by dietpepsi
No comments:
Post a Comment