Add Python solution for Valid Parentheses (Closes #317)#412
Open
maitriupadhyay03-cell wants to merge 3 commits into
Open
Add Python solution for Valid Parentheses (Closes #317)#412maitriupadhyay03-cell wants to merge 3 commits into
maitriupadhyay03-cell wants to merge 3 commits into
Conversation
Implemented a function to find the longest common prefix among an array of strings using horizontal scanning. Added test cases to validate the functionality.
Implement Kadane's Algorithm to find the maximum sum of a contiguous subarray with test cases.
Add a Python solution for the Valid Parentheses problem using a stack-based approach. - Time Complexity: O(n) - Space Complexity: O(n) - Includes 7 test cases covering all edge cases Closes saloni-jaiswal-dev#317
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a Python solution for the Valid Parentheses problem using a stack-based approach.
Closes #317
Problem
Given a string
scontaining just the characters(,),{,},[and], determine if the input string is valid.A string is valid if:
Approach
(,{,[→ push onto the stack.),},]→ check if the top of the stack is the matching opener.Complexity
Test Cases
"()"True"()[]{}"True"(]"False"([)]"False"{[]}"True""True"{"False