What does the acronym LIFO mean?
last in first out
What methods are available on a Stack data structure?
push, pop, print, peek
What must you do to access the value at an arbitrary point in a stack (not just the “top”)?
continuously pop until you reach that point in the stack
Are braces balanced (interview question: algo challenge)
- take a string containing brackets, braces, parentheses,
- return boolean to say if the string’s braces are balanced
solution
- for each char, check if opening brace
- if yes, push it on to stack
- if closing brace,
- if the stack’s top is matching opening brace, pop it
- if the stack’s top is not matching return false