Welcome to LeetCode Discuss.  Please read the FAQ to help yourself making the best use of Discuss.
Ask a Question
Back to Problem

Welcome to LeetCode Discuss.

This is a place to ask questions related to only OJ problems.

Please read the FAQ to help yourself making the best use of Discuss.

Vague output value.

0 votes
254 views

In this question

In the description input )()()) output is 4

while in OJ input ()(() output is 2

However there are 4 length balance parenthesis in ()(().

Could some one explain the reason/difference between these two format.

Thanks in advance.

asked Jan 27 in Longest Valid Parentheses by gautamnitc (610 points)

1 Answer

+3 votes

This question asks for substring instead of subsequence. ()() is a subsequence of ()(() not a substring while () is the longest balanced parenthesis substring for ()(()

answered Jan 27 by TheFallenPrime (230 points)

Thanks , I overlooked that point.


...