|
|
|
|
|
by vidarh
219 days ago
|
|
Depends. You want a stack, as it's certainly more efficient, but if you can rewind the position pointer you don't need one (you can count backwards). EDIT: It gets complicated if you need to count multiple different types of openers. In that case I think you need the stack, at least unless there are constraints on which openers can occur within others - you at the very least need to know which closer you're looking for right now, but if you can't deduce what is outside, you obviously then need to keep track of it. In practice, of course, we'll generally use a stack because it's just pointless to make life harder by not using one for this. |
|
You NEED a stack.
(And no, I didn't presume anything ... I addressed rewinding above.)