c++


  • 0
    E

    class Solution {
    public:
    string reverseStr(string s, int k) {
    if(s=="")return "";
    int size = s.length();
    string ss;
    int count = size%(2k)==0?size/(2k):size/(2k)+1;
    for(int i =0;i<count;i++){
    for(int j= i
    2k+k>size?size-1:i2k+k-1;j>=i2k;j--){
    ss+=s[j];
    }
    for(int j = i
    2*k+k;j<size&&j<(i+1)2k;j++){
    ss+=s[j];
    }
    }
    return ss;
    }
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.