LC 344. Reverse String

Nilanjan Deb · April 5, 2020

This is my CPP solution.

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


Dicussion Forum