Leetcode June Challenge - Day 4

Problem: LeetCode June Challenge - Day 4

Ideas:

  1. Swap every character with it’s opposite.

Solution:

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