so I know this isn't the best way to find a max sequence in a string but it was a work in progress and an idea, problem is I couldn't even get it to run.
I kept getting Debug assertion failure string subscript out of range, I played with all sorts of stuff but with no luck. I replaced the appends and clears with assigns and all sorts of stuff but just never got it to run with "Debug assertion failure string subscript out of range" :(.
You never check to make sure j is less than nextsequence.length()
You then use j to index nextsequence on line 21.
Since you are clearing nextsequence on lines 28 and 32, it's almost certain that j will be greater than nextsequence's length. Hence why you're getting the out of bounds message.
Also, why are you starting at 1 everywhere? Indexes start at 0.