Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE

Problem: The string "PAYPALISHIRING" is written in a zigzag on 3 rows (letters go down the rows in a zigzag, then the rows are read left to right). What is the 5th character (1-indexed) of the resulting string?

  1. A. P
  2. B. H
  3. C. A
  4. D. N

Correct answer: C. A

Build the row buckets by bouncing between the top and bottom rows, then concatenate them. Reading the zigzag column by column gives a different string.

More Coding Interview Problems questions

Exams that ask this topic