Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
RadioactiveMan
on Feb 26, 2015
|
parent
|
context
|
favorite
| on:
Problem Solving with Algorithms and Data Structure...
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.
msoad
on Feb 26, 2015
[–]
You can still use an index for each symbol and track diff of child vs. parent and make sure it's never negative.
nitishmd
on Feb 26, 2015
|
parent
[–]
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?
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: