Hello Veeky Forums

It has to be recursive

You could just put a while loop at the end that checks the index of the first non '(' element and then puts check that is neither '(' nor ')' before it.

It's recursive. No loops can be used.

>lets see if there's anybody relatively smart on here.
seriously?

all you have to do is change the last line to
return str;

>seriously?
That doesn't work.. Did you even read?

Then implement that loop recursively

You can't just switch the position of the character like that, this isn't an array.

A string is exactly an array of chars. You can just use two substrings once you know the number of the first letter/last '('. Use another recursive function to get the number and it's easy.

But since this is sorting, the substrings will get smaller, and anything that calls for an index greater than 1 after a couple passes will throw an out of bounds exception.

I think the question is easier by saying, What do i need to return when they aren't "(" or ")"

& this has to work for any given input, not just the test case.