Put your new knowledge of stacks to use with this practice interview question. Write a function that makes use of a stack to determine whether or not a string containing common Python punctuation characters contains balanced pairs of those symbols.
(swooshing)…- [Narrator] Now that we've implemented…the stack data structure using Python,…let's put it into practice.…In this challenge, your prompt is to create a function…that takes in a string of symbol pairs as a parameter.…The function should return true if the symbol string…is balanced or false if it isn't.…Here's what we mean by a symbol string.…The string should only contain opening and closing symbols…like open and closed parenthesis,…open and close square brackets,…or open and close curly braces.…
This is to mimic what happens in your text editor…when the linter is checking…for whether or not you remembered…to close all of your opening symbols.…In order for symbols to be balanced,…each opening symbol should also have a closing symbol.…And the symbols must be properly nested.…You should, of course, make use of a stack in your solution.…Here are some examples of what I mean by balanced symbols.…And here are examples of unbalanced symbols.…
It's pretty obvious.…Feel free to come up with your own solution…
- Abstract types and data structures
- Stacks as a linear abstract data type
- Creating the Stack class and its methods
- Adding items to the top and bottom of a stack
- Creating the Queue class and its methods
- Manipulating items in a queue
- Creating the Dequeue class and its methods
- Adding and removing items from a dequeue
Skill Level Advanced
Learning the Python 3 Standard Librarywith Kathryn Hodge2h 9m Intermediate
What you should know1m 26s
1. Abstract Data Types and Data Structures
2. The Stack
3. The Queue
4. The Deque
Next steps1m 43s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.