problem
solution:
class Solution { public: string reverseOnlyLetters(string S) { for(int i=0, j=S.size()-1; i<j; )//err... { if(!isalpha(S[i])) i++; else if(!isalpha(S[j])) j--; else { char tmp = S[i]; S[i] = S[j]; S[j] = tmp; i++; j--; } } return S; } };
参考
1. Leetcode_easy_917. Reverse Only Letters;
完