Solved Valid Parentheses in Java with Stack

Day 9 of #100DaysOfLeetCode 💻✅ Solved Valid Parentheses problem in Java using Stack. Approach: Used a stack to store opening brackets Pushed opening brackets ( { [ into the stack When a closing bracket appeared, checked if it matches the latest opening bracket Returned false if mismatch or stack becomes empty unexpectedly Finally checked if stack is empty to confirm valid parentheses Performance: ✓ Runtime: 3 ms (Beats 87.85%) ✓ Memory: 43.29 MB (Beats 70.02%) Key Learning: ✓ Strengthened understanding of Stack data structure ✓ Improved bracket matching and string traversal logic Learning and improving one problem every single day 🚀 #Java #LeetCode #Stack #ProblemSolving #CodingJourney #100DaysOfCode #DSA

  • graphical user interface, application

To view or add a comment, sign in

Explore content categories