Given you the answer is too trivial but it is not going to help you to learn.
Programming aside, what would you do if you have to solve it manually without computer:
Let n starts from 0, i.e. n = 0, loop
1. Pick out the nth letter in the test array
1.1. m = n + 1, loop
1.2. pick out the mth letter in the test array, concatenate with the nth letter
1.3. If there is any letter after mth, then
1.3.1. m = m + 1
1.3.2. Goto 1.2
else
1.3.3. n = n +1
1.3.4 goto 1
I see that you can make the first for loop worked, now translate the above into another for loop. After all, that is your homework.