Google interview question

Stack question, similar to modified Valid parantheses