Episode #5
Coding Challenge - Balanced Brackets
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: https://github.com/hello-rust/show/pull/31)
▶ Run and edit the code on Gitpod
Keywords
Into trait, Pattern matching, HashMap, Stack, unreachable! macro, coding puzzle, competitive programming
Things I mentioned during the show
- 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
Things I should have mentioned (but forgot)
- Thanks to @barskern who found a major bug in the code
- More coding puzzles at my Github repository
Resources and licenses
- Bavarian Seaside by KevinMacLeod
- Coin sound by ProjectsU012
- Blip sound by ProjectsU012
- Mystery sound by FoolBoyMedia
Support!
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. ❤️