Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)

Code Block
P   A   H   N
A P L S I I G
Y   I   R


And then read line by line: "PAHNAPLSIIGYIR"

...

Code Block
Input: s = "PAYPALISHIRING", numRows = 4
Output: "PINALSIGYAHRPI"


Explanation:

Code Block
P   I   N
A L S I G
Y A H R
P   I