We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class Solution { public: string convert(string s, int numRows) { if (numRows <= 1) { return s; } vector<string> v(numRows, ""); int j = 0, dir = -1; for (int i = 0; i < s.length(); i++) { if (j == numRows - 1 || j == 0) { dir *= -1; } v[j] += s[i]; if (dir == 1) j++; else j--; } string res; for (auto &it : v) { res += it; } return res; } }; // if numsRows = 3 // 0, 4, 8, 12 // 1, 3, 5, 7, 9, 11, 13 // 2, 6, 10 // if numsRows = 4 // 0, 6, 12, // 1, 5, 7, 11,13, // 2, 4, 8, 10, 14, // 3, 9, 15, // 배열을 N개만큼 만들고 현재 인수에서 N개까지 증가, N개만큼 감소 반복. // 배열 순서대로 붙이기
The text was updated successfully, but these errors were encountered:
fkdl0048
No branches or pull requests
The text was updated successfully, but these errors were encountered: