Write a string s in a zigzag shape across numRows rows. Start at the top row and put one letter at a time going down. When you reach the bottom row, go up one row at a time, one column to the right each step. At the top, go down again, and keep going till the string ends.
For example, "CRICKETFANS" on 3 rows looks like this:
C K A
R C E F N
I T S
Now read the zigzag row by row, from the top row to the bottom row, left to right. You get "CKARCEFNITS".
Given s and numRows, return the string you get by reading the zigzag row by row.
Examples
Example 1:
Input: s = "CRICKETFANS", numRows = 3
Output: "CKARCEFNITS"
Explanation: This is the shape shown above. Row by row: "CKA", "RCEFN", "ITS".
Example 2:
Input: s = "CRICKETFANS", numRows = 4
Output: "CTREFIKASCN"
Explanation: The shape has 4 rows: "CT", "REF", "IKAS" and "CN". Read them one after the other.
Example 3:
Input: s = "GO", numRows = 5
Output: "GO"
Explanation: The string is shorter than the number of rows, so every letter is in its own row, and the order does not change.