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?
- A. P
- B. H
- C. A
- 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
- Problem: How many ordered pairs (i, j) with 1 ≤ i < j ≤ 10 satisfy i XOR j = 3?
- Problem: In how many ways can 100 be written as a sum of two perfect squares x² + y² with 0 ≤ x ≤ y (unordered, non-negative)?
- Problem: How many prime numbers are there in the range 1 to 200 (inclusive)?
- Problem: Compute σ(360), the sum of all positive divisors of 360.
- Problem: The gas-station problem: gas = [1, 2, 3, 4, 5] and cost = [3, 4, 5, 1, 2] around a circular route of 5 stations, starting with an…
- Problem: Children with greed factors g = [1, 2, 3] and cookies s = [1, 1] (each child takes at most one cookie, and a cookie of size ≥ the…