class Solution {
public:
string convert(string s, int numRows) {
if (numRows <= 1) {
return s;
}
vector<string> res(numRows, "");
int step = 1, row = 0;
for (int i = 0 ; i < s.size(); i++) {
res[row] += s[i];
if (row == 0) {
step = 1;
}
if (row == numRows - 1) {
step = -1;
}
row += step;
}
string str;
for (int i = 0 ; i < numRows; i++) {
for (int j = 0 ; j < res[i].size(); j++) {
str += res[i][j];
}
}
return str;
}
};