Skip to content

Anand8595/java-Solution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Longest Valid Parentheses - Java

Problem

Given a string containing only '(' and ')', return the length of the longest valid (well-formed) parentheses substring.

Approach

This solution uses a stack to store indices of parentheses. It scans the string once and calculates the maximum length of a valid parentheses substring.

Time Complexity

O(n)

Space Complexity

O(n)

How to Run

javac Solution.java
java Solution

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages