Using a stack to compare letters in a string

So I have to write a code and must you a stack, to determine if the sequence is is in the form of X^nY^n.
Last edited on
I am not sure what is wrong with your code, it seems unnecessarily complicated to me. The only problem I can find is seq[i+1]!='A'. You would be trying to access memory outside the array when i == seq.length() - 1.
Topic archived. No new replies allowed.