#C9743. Zigzag Conversion
Zigzag Conversion
Zigzag Conversion
The problem is to convert a given string into a zigzag pattern on a given number of rows and then read the pattern line by line to produce the output string. More formally, given a string (s) and an integer (numRows), you should write the string in a zigzag form and then concatenate the characters row by row to form the final result. For example, for (s = \texttt{PAYPALISHIRING}) and (numRows = 3), the zigzag pattern is:
[ P A H N A P L S I I G Y I R ]
Reading row by row gives the answer (\texttt{PAHNAPLSIIGYIR}).
inputFormat
The first line of input contains a non-empty string (s). The second line contains an integer (numRows) representing the number of rows for the zigzag pattern.
outputFormat
Output a single line containing the string formed by reading the zigzag pattern line by line.## sample
PAYPALISHIRING
3
PAHNAPLSIIGYIR