class Solution {
public:
string convert(string s, int numRows) {
if (numRows == 1) return s;
vector<string> arr(numRows);
int row = 0, step = 1;
for (int i = 0; i < s.length(); ++i) {
arr[row].push_back(s[i]);
if (row == 0) step = 1;
else if (row == numRows - 1) step = -1;
row += step;
}
string ret;
for (const string& str : arr) {
ret += str;
}
return ret;
}
};