# Leetcode 344. Reverse String ###### tags: `Leetcode(C++)` 題目 : https://leetcode.com/problems/reverse-string/ 。 想法 : 轉拔,頭跟尾。 時間複雜度 : O(n)。 程式碼 : ``` class Solution { public: void reverseString(vector<char>& s) { int l=s.size(); char tmp; for(int i=0 ; i<l/2 ; i++){ tmp=s[i]; s[i]=s[l-i-1]; s[l-i-1]=tmp; } return; } }; ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up