aboutsummaryrefslogtreecommitdiff
path: root/reverse_string.cpp
blob: f5940a084af1086d9b7dbd693fa9eee5f8c77b78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "leetcode.h"

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