#C14045. Zigzag Conversion

    ID: 43651 Type: Default 1000ms 256MiB

Zigzag Conversion

Zigzag Conversion

Given a string s and an integer numRows, arrange the characters of s in a zigzag pattern on numRows rows, and then read the pattern line by line to form a new string.

For instance, if s = "PAYPALISHIRING" and numRows = 3, the zigzag formation is as follows:
[ \begin{array}{ccccccc} P & & A & & H & & N \ & A & & P & L & S & I \ & & Y & & I & & R \end{array} ]
The output is "PAHNAPLSIIGYIR".

Note: When numRows is 1 or greater than or equal to the length of s, the output is simply s.

inputFormat

The input consists of two lines:
1. A non-empty string s.
2. An integer numRows representing the number of rows for the zigzag pattern.

outputFormat

Output the transformed string after applying the zigzag conversion.## sample

PAYPALISHIRING
3
PAHNAPLSIIGYIR