# 344-Reverse String ###### tags: `Easy` ## Question https://leetcode.com/problems/reverse-string/ ## Key 1. use a new string back store original string 2. swap front and behind (in-place) ## Reference ## Solution ```cpp= class Solution { public: void reverseString(vector<char>& s) { char j = 'a'; for (int i = 0; i < s.size() / 2; i ++ ){ j = s[i]; s[i] = s[s.size() - i - 1]; s[s.size() - i - 1] = j; } } }; ```
×
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