News for hackers. Stuff that matters.
Re:Problem Solving with Algorithms and Data Structures by RadioactiveMan on Thursday February 26, 2015 @03:00PM (#9115052)
If you're working with multiple symbols, such as (), {}, and [], you'd want to use a stack. Closing a child ( before its parent { would be an error.
Re:Problem Solving with Algorithms and Data Structures by msoad on Thursday February 26, 2015 @03:28PM (#9115247)
You can still use an index for each symbol and track diff of child vs. parent and make sure it's never negative.
Re:Problem Solving with Algorithms and Data Structures by nitishmd on Thursday February 26, 2015 @04:36PM (#9115677)
Wouldn't the worst case space complexity be the same then? for eg: ( { [ ] } ) as you will be keeping index for each the symbols. Technically it can be implemented, but isn't stack a better approach?