Welcome to the daily solving of our PROBLEM OF THE DAY with Nitin Kaplas We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Tree but also build up problem-solving skills.
Given a string str consisting of opening and closing parenthesis '(' and ')'. Find length of the longest valid parenthesis substring.
A parenthesis string is valid if:
- For every opening parenthesis, there is a closing parenthesis.
- Opening parenthesis must be closed in the correct order.
Examples :
Input: str = ((()
Output: 2
Explaination: The longest valid parenthesis substring is "()".
Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/longest-valid-parentheses5657/1