Here is the code:
class Solution {
public void reverseString(char[] s) {
int j = s.length-1;
System.out.print("[");
char ch = '"';
for(int i = j; i >= 0 ; i--)
{
System.out.print(ch);
System.out.print(s[i]);
System.out.print(ch);
System.out.print(",");
}
System.out.print("]");
}
}
Your input
["h","e","l","l","o"]
my output:
stdout
["o","l","l","e","h",]
Expected
["o","l","l","e","h"]
I just want to remove the extra ,
(comma) from my output. what should I do or change?