Skip to content

Conversation

@Gokul45-45
Copy link

Description

This PR adds the Valid Parentheses algorithm implementation using Stack data structure.

Problem

Checks if a string containing parentheses (), brackets [], and braces {} is valid according to:

  • Open brackets must be closed by the same type
  • Open brackets must be closed in the correct order

Changes Made

  • Added ValidParentheses.java in stacks package
  • Added comprehensive unit tests in ValidParenthesesTest.java
  • Includes edge case handling (null, odd length, empty string)

Testing

  • All tests pass locally
  • Covers valid cases: (), ()[]{}, {[]}
  • Covers invalid cases: (], ([)], {{{

Closes #6724

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.51%. Comparing base (f693c44) to head (7a68d2e).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ava/com/thealgorithms/stacks/ValidParentheses.java 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7117   +/-   ##
=========================================
  Coverage     78.50%   78.51%           
- Complexity     6752     6758    +6     
=========================================
  Files           759      760    +1     
  Lines         22402    22418   +16     
  Branches       4400     4404    +4     
=========================================
+ Hits          17587    17601   +14     
- Misses         4109     4110    +1     
- Partials        706      707    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Gokul45-45
Copy link
Author

@DenizAltunkapan
could u please check and review the changes ,i would appereciate a quick response
,thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Valid Parenthesis using Java

2 participants