[ENHANCEMENT] Replacing Parenthesis Algorithm
11-aryan opened this issue · comments
What would you like to share?
In #492, the algorithm for checking parenthesis seems to be redundant, as it merely checks if all the opened parenthesis are closed or not. Instead, a better algorithm would be to check if the parenthesis is valid or balanced, which is a very standard algorithm.
Extra issue details
For example, in the parenthesis sequence )))(((
, the current algorithm would return true
as initially, the parcounter
is decremented due to )
and then later incremented, eventually becoming 0, but this is invalid as the )
has started before (
.
Additional information
No response
I have the optimized implementation for this. Can I create a PR if this issue is valid ?
Don't open issues for missing algorithms. Just open a pr and it will be reviewed.
Should that be added as a new algorithm ?
Sure.
What about the existing one ?
Since its an improvement, you can replace the existing algorithm.