Python icon indicating copy to clipboard operation
Python copied to clipboard

Added Valid Parentheses algorithm in Python

Open manikonda-anjali opened this issue 1 month ago • 0 comments

Description

This pull request adds a Python implementation of the Valid Parentheses algorithm.
The algorithm checks whether a given string of brackets is valid, ensuring that every opening bracket has a corresponding closing bracket in the correct order.

Changes Made

  • Added a new file: algorithms/valid-parentheses.py
  • Implemented a clean and efficient solution using a stack-based approach.
  • Included example test cases in code comments for clarity.

Example

Input: "()[]{}" Output: True

Input: "(]" Output: False

Checklist

  • [x] Code follows the repository’s style guidelines.
  • [x] Code is properly formatted and readable.
  • [x] Implementation has been tested locally.
  • [x] New file is placed in the correct directory (algorithms/).
  • [x] Commit message is descriptive.

Additional Notes

This implementation is intended for educational purposes as part of the open-source Algorithms in Python collection. It provides a clear example of stack usage in validating expressions.

manikonda-anjali avatar Nov 02 '25 10:11 manikonda-anjali