Write a function that takes a string as input and returns the string reversed. 造一个方法让输入的的字符串反转(这个不用谷歌我也可以翻译hh) Example: Given s = “hello”, return “olleh”.
直接贴代码:
class Solution {public: string reverseString(string s) { int i=0,j=s.size()-1; while(i<j) { swap(s[i],s[j]); i++; j--; } return s; }};新闻热点
疑难解答
图片精选