Today we will do a quick interview question called "balanced brackets"
I maintain a list of common interview questions on Github, that is perfect for some quick fun exercise from time to time. In this case I'd like to introduce you to a task called "balanced brackets", which is some sort of state machine, to check if an input consisting of brackets has exactly one closing bracket for each opening bracket. (Psst... I'm hiding a bug in my code, can you find it? 😉 Answer here: #31)
If you like to get notified about new episodes, please subscribe to my channel 😊.
Keywords: Into trait, Pattern matching, HashMap, Stack, unreachable! macro, coding puzzle, competitive programming
- Unreachable macro: https://doc.rust-lang.org/std/macro.unreachable.html
- Into trait: https://doc.rust-lang.org/std/convert/trait.Into.html
- Creating a Rust function that accepts String or &str: https://hermanradtke.com/2015/05/06/creating-a-rust-function-that-accepts-string-or-str.html
- Thanks to @barskern who found a major bug in the code
- More coding puzzles at my Github repository
- Bavarian Seaside by KevinMacLeod
- Coin sound by ProjectsU012
- Blip sound by ProjectsU012
- Mystery sound by FoolBoyMedia
Preparing, recording, and editing an episode takes a substantial amount of time (around 30 hours total). I do all of this next to my fulltime dayjob. If you want to show your appreciation and help me keep the content free for everybody to enjoy, please consider sponsoring me on Github - no matter the amount. ❤️