Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

344. Reverse String c++

class Solution {
public:
    void reverseString(vector<char>& s) {
        int i=0;
        int j=s.size()-1;
        while(i<j)
        {
            swap(s[i],s[j]);
            i++;
            j--;
        }
    }
};

//Runtime: 20 ms, faster than 76.31% of C++ online submissions for Reverse String.
//Memory Usage: 23.3 MB, less than 38.31% of C++ online submissions for Reverse String.
Source by codejudge.blogspot.com #
 
PREVIOUS NEXT
Tagged: #Reverse #String
ADD COMMENT
Topic
Name
8+7 =