zoukankan      html  css  js  c++  java
  • Leetcode-917 Reverse Only Letters(仅仅反转字母)

     1 class Solution
     2 {
     3     public:
     4         string reverseOnlyLetters(string S)
     5         {
     6             string onlyLetter;
     7             for(auto c:S)
     8             {
     9                 if(isalpha(c))
    10                     onlyLetter += c;
    11             }
    12             reverse(onlyLetter.begin(),onlyLetter.end());
    13             for(int i = 0,j = 0;i < S.size();i ++)
    14             {
    15                 if(isalpha(S[i]))
    16                 {
    17                     S[i] = onlyLetter[j++];
    18                 }
    19             }
    20             return S;
    21         }
    22 };
  • 相关阅读:
    字体
    abstract关键词
    final关键词
    多态
    接口
    java面向对象
    java运算符
    JDK安装
    循环
    TextView控件
  • 原文地址:https://www.cnblogs.com/Asurudo/p/9762265.html
Copyright © 2011-2022 走看看