Problem Description:
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = “hello”, return “olleh”.
题目大意:
反转一个给定字符串
Solutions:
简单的倒序添加每一个字符即可
Code in C++:
class Solution {
public:
string reverseString(string s) {
string res="";
for(int i = 0; i<s.length();i++)
res=s[i]+res;
return res;
}
};
近期评论