Zigzag Conversion

Asked atPayPal
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Return early when one row or rows exceed length.
  2. 02Keep one builder per row and current direction.
  3. 03Append each character then reverse direction at boundaries.
  4. 04Concatenate row builders.

Reference answer

Then expect these follow-ups

  • What is the cycle length for a direct-index solution?

    Tests: patterns

  • Why are builders preferable to repeated string concatenation?

    Tests: performance

Hiring now

PayPal has 254 open roles right now

landed applies to roles like these for you, on each company’s own site, with answers written for the role.

Get 5x interviews10 free auto-applies. No card.
  • Sr Software Engineer

    Bangalore, Karnataka, India

  • Sr Software Engineer (Full Stack – React / Node.js / Java)

    Bangalore, Karnataka, India

  • Software Engineer

    Scottsdale, Arizona, United States of America

Or practice this question first

Next question