Logspace algorithm for balanced parentheses problem Currently I want to learn the complexity of space, I read a few of the books on it. On this I encountered this example problem. I would just like to know how to show that the following problem $​\in L $ (deterministic logarithmic space).

Input:  series of open or closed parentheses

Question: Are these parentheses properly balanced?

Example:  $((() ()) (()))$ should be accepted but $()) ()$ should be rejected.​
Initialize a counter at zero. Whenever you see "(", increase it by one, and whenever you see ")", decrease it by one. Accept if the counter was always nonnegative and ended up at zero. The counter only takes logarithmic space to store.