Total Accepted: 10975
Total Submissions: 18784
Difficulty: Easy
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
Subscribe to see which companies asked this question
Show Similar Problems
Have you met this question in a real interview?
Yes
No
我的解法就是一般的一个一个拆开再赋值:
class Solution {
public:
string reverseString(string s) {
string s1;
int i;
for(i=s.length()-1;i>=0;i--){
s1+=s[i];
}
return s1;
}
};
我还在想其他的好方法,谢谢大家啦^_^