Write the string s in a zigzag pattern on numRows rows: go straight down the rows, then diagonally back up to the top, and repeat. Then read the pattern row by row, left to right, and return the resulting string.
Write the string s in a zigzag pattern on numRows rows: go straight down the rows, then diagonally back up to the top, and repeat. Then read the pattern row by row, left to right, and return the resulting string.
Example 1:
Input: {"s":"PAYPALISHIRING","numRows":3}
Output: PAHNAPLSIIGYIR
Constraints:
1≤s.length≤1000
s consists of English letters (lower-case and upper-case), , and ..
1≤numRows≤1000
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"PAYPALISHIRING","numRows":3}
numRows = 3 is between 2 and len(s) - 1 = 13, so the characters really zigzag.