leetcode917
生活随笔
收集整理的這篇文章主要介紹了
leetcode917
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
class Solution {
public:string reverseOnlyLetters(string S) {int len = S.length();queue<char> Q;stack<char> ST;vector<int> V;for (int i = 0; i < len; i++){char c = S[i];//小寫 ASCII[97,122]//大寫 ASCII[65,90]if ((c >= 97 && c <= 122) || (c >= 65 && c <= 90))//字母
{ST.push(c);}else//符號
{Q.push(c);V.push_back(i);}}string R;for (int i = 0; i < len; i++){char c = 0;if (find(V.begin(), V.end(), i) == V.end())//當前應(yīng)該是一個字符
{c = ST.top();ST.pop();}else{c = Q.front();Q.pop();}R += c;}return R;}
};
?
轉(zhuǎn)載于:https://www.cnblogs.com/asenyang/p/9751479.html
總結(jié)
以上是生活随笔為你收集整理的leetcode917的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux网络协议栈(一)——Socke
- 下一篇: 网关服务器