how about the following code?


  • 0
    Q

    class Solution {
    public:
    string reverseString(string s) {
    string s1;
    for(std::string::reverse_iterator rit=s.rbegin();rit!=s.rend();++rit)
    s1.push_back(*rit);
    return s1;
    }
    };


Log in to reply
 

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