solution to ZigZag Conversion