Description
Submission
class Solution { public: string reverseOnlyLetters(string s) { int n = s.size(); for(int i = 0, j = n - 1; i < j; ++i, --j) { while(i < n && !isalpha(s[i])) ++i; while(j >= 0 && !isalpha(s[j])) --j; if(i < j) swap(s[i], s[j]); } return s; } };