Zigzag Conversion
Given a string s and an integer numRows, write s in a zigzag pattern down and up across numRows rows, then read the pattern row by row to produce a new string. Return that concatenated string.
Open official problem prompt ↗Re-order the characters of a string so that they read out in the order a zigzag path would visit them across numRows rows.
Imagine writing a message on a set of horizontal lines while your pen bounces down to the bottom line and back up to the top, like a ping-pong ball; afterward you read each line left to right.
- Input
- s = "PAYPALISHIRING", numRows = 3
- Output
- "PAHNAPLSIIGYIR"
- Why
- Row 0 is P A H N, row 1 is A P L S I I G, row 2 is Y I R; concatenated they give PAHNAPLSIIGYIR.
1 <= s.length <= 1000s consists of English letters (lower-case and upper-case), ',' and '.'1 <= numRows <= 1000