Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
Subscribeto see which companies asked this question.
Hide Tags
Hide Similar Problems
(E) Reverse Vowels of a String
public class Solution {
public String reverseString(String s) {
int length = s.length();
char[] result = new char[length];
for(int i=0;i<length;i++){
result[i] = s.charAt(length-1-i);
}
return new String(result);
}
}