Simple c++ solution (no swap)


  • 0
    class Solution {
    public:
        string reverseString(string s) {
            string reversedString = "";
            for(int i = s.length() - 1; i >= 0; i--){
                reversedString += s.at(i);
            }
            return reversedString;
        }
    };
    

Log in to reply
 

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