The algorithm: Create an empty stack For each character in the string: - If it's an opening bracket, push it onto the stack - If it's a closing bracket: - If stack is empty, return false (no matching open bracket) - Pop the top. If it doesn't match, return false. After processing all characters, return true only if stack is empty An empty stack at the end means all brackets were matched.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/stacks/valid-parentheses-solution
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████████████████