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; }};新聞熱點
疑難解答
圖片精選