葉林
Linked with GitHub
# LeetCode - 0917. Reverse Only Letters ### 題目網址:https://leetcode.com/problems/reverse-only-letters/ ###### tags: `LeetCode` `Easy` `字串` ```cpp= /* -LeetCode format- Problem: 917. Reverse Only Letters Difficulty: Easy by Inversionpeter */ class Solution { public: string reverseOnlyLetters(string S) { int first = 0, second = S.size() - 1; while (1) { while (first != S.size() && !isalpha(S[first])) ++first; while (second >= 0 && !isalpha(S[second])) --second; if (first >= second) break; swap(S[first], S[second]); ++first; --second; } return S; } }; ```
×
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