Problem
This problem was asked by PayPal.
Given a string and a number of lines, print the string in a zigzag form. In zigzag, characters are printed out diagonally from top left to bottom right until reaching the kth
line, then back up to top right, and so on.
For example, given the sentence "thisisazigzag"
and k = 4
, you should print:
—————————————————————…
Keep reading with a 7-day free trial
Subscribe to Technology Made Simple to keep reading this post and get 7 days of free access to the full post archives.