Blackbaud interview question

String pattern and stack operation