The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this:
And then read line by line: "PAHNAPLSIIGYIR"
Input: s = "PAYPALISHIRING", numRows = 3
Output: "PAHNAPLSIIGYIR"
Input: s = "PAYPALISHIRING", numRows = 4
Output: "PINALSIGYAHRPI"
Explanation:
Input: s = "A", numRows = 1
Output: "A"
1 <= s.length <= 1000s consists of English letters (lower-case and upper-case), ',' and '.'.1 <= numRows <= 1000The problem asks to reorder the given string in a specified zigzag pattern across multiple rows. The basic idea here is direct simulation by creating an array of strings, each representing a row in the zigzag pattern.