LeetCode 20. Valid Parentheses, solved using Python

Publié le: 01 juillet 2021
sur la chaîne: buckmasterinstitute
355
1

LeetCode 20. Valid Parentheses | Python

Created and recorded by Aman Chhina. June 2021

Overview

1. Understand the problem.
2. The intuition of how to tackle the problem
3. Develop algorithm
4. Code the solution.

Script

Link to Problem: https://leetcode.com/problems/valid-p...

Introduction to the problem, and clarify what constitutes a valid parentheses sequence.

Clarify our intuition of how we would visually look at the sequence to determine whether it is valid or invalid.

Translate this to an appropriate algorithm we can use, which will be based on updating the last opening parentheses with the first closed parentheses.

Explain how a Stack and it's LIFO policy will be a best fit for our algorithm and go through rough details of what the algorithm will look like, as well as some edge cases such as the stack being empty when looking at a closing parentheses or the stack still having elements after iterating over the complete string.

Code up our algorithm, explaining the different cases and edge cases. Simplify our solution by using a dictionary to check whether the current character's valid open parenthesis corresponds to the element that's located in our stack.


Sur cette page du site, vous pouvez voir la vidéo en ligne LeetCode 20. Valid Parentheses, solved using Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur buckmasterinstitute 01 juillet 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 355 fois et il a aimé 1 téléspectateurs. Bon visionnage!