v2 time O(n) space O(n) Accepted

pretty easy though question is not very clear. 

in v1 (which is not checked in), forgot to append content in stack to sb outside of for loop