6. Zigzag Conversion

MediumString

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) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR". Write the code that will take a string and make this conversion given a number of rows.

Examples

Input: PAYPALISHIRING 3

Output: PAHNAPLSIIGYIR

Explanation: Written in 3 rows of zigzag, then read row by row.

Constraints

  • 1 <= s.length <= 1000
  • s consists of English letters (lower-case and upper-case), ',' and '.'.
  • 1 <= numRows <= 1000
Loading...

Run checks all cases above. Submit evaluates all test cases.