0
Help with string reverse
Don't know where I'm going wrong here. Any help would be appreciated. https://code.sololearn.com/cZdFjiQq6oD6/?ref=app
6 Antworten
+ 1
You are complicating the code by introducing a new list.
You have a string which needs to be reversed, and a piece of code which will iterate through that string in reverse.
Why not just print out the letters as the code iterates
for(int i=arr.length-1; i>=0; i--){
System.out.print(arr[i]);
}
+ 2
This part:
for(int i = arr.length-1; i >=0; i--)
+ 1
Rik Wittkopp I edited it and it seems to work perfectly. However there are two hidden test cases that are coming up wrong.
+ 1
Yeah you're right that's far simpler.
+ 1
I am a simple man 🤣😂
0
That worked perfectly thanks for the help! Simpler is always better idk why I thought I needed to store all the characters first haha