Added test cases for LongestValidParentheses

This commit is contained in:
Omkarnath Parida
2021-10-03 20:58:53 +05:30
parent c2b3931391
commit db3caea70f
2 changed files with 20 additions and 9 deletions

View File

@ -5,7 +5,7 @@
find the length of the longest valid (well-formed) parentheses substring.
*/
const longestValidParentheses = (s) => {
export const longestValidParentheses = (s) => {
const n = s.length
const stack = []
@ -33,11 +33,3 @@ const longestValidParentheses = (s) => {
res.push(0)
return Math.max(...res)
}
const main = () => {
console.log(longestValidParentheses(')()())')) // output -> 4
console.log(longestValidParentheses('')) // output -> 0
console.log(longestValidParentheses('(()')) // output -> 2
}
main()