As reported: PayPal Senior Software Engineer (2026), second DSA round (the third round overall): LeetCode Zigzag Conversion.
The string s is written in a zigzag pattern on numRows rows: down the first column from row 0 to row numRows - 1, then diagonally up to row 0, then down again, and so on. Return the string read row by row, left to right.
This is LeetCode 6 — Zigzag Conversion.
Example 1
s = "PAYPALISHIRING", numRows = 3 -> "PAHNAPLSIIGYIR"
P A H N
A P L S I I G
Y I R
Example 2
s = "PAYPALISHIRING", numRows = 4 -> "PINALSIGYAHRPI"
Example 3
s = "A", numRows = 1 -> "A"
Constraints: 1 ≤ s.length ≤ 1000; 1 ≤ numRows ≤ 1000; English letters, , and ..
Code runner format: one JSON value per line (LeetCode's test-case format): s, then numRows. Implement convert(s, numRows); the harness prints the string you return.