@@ -0,0 +1,928 @@
+public class ZigZagConversion %7B%0A    public static String convert(String s, int numRows) %7B%0A        if (numRows == 1) return s;%0A        int len = s.length(), step = numRows * 2 - 2;%0A        StringBuilder sb = new StringBuilder();%0A        // top line%0A        for (int i = 0; i %3C len; i += step) %7B%0A            sb.append(s.charAt(i));%0A        %7D%0A        // middle lines;%0A        for (int i = 1; i %3C numRows - 1; i++) %7B%0A            int interval = i * 2;%0A            for (int j = i; j %3C len; j += interval) %7B%0A                sb.append(s.charAt(j));%0A                interval = step - interval;%0A            %7D%0A        %7D%0A        // bottom line%0A        for (int i = numRows - 1; i %3C len; i += step) %7B%0A            sb.append(s.charAt(i));%0A        %7D%0A        return sb.toString();%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A       System.out.println(convert(%22PAYPALISHIRING%22, 3)); %0A       System.out.println(convert(%22ABC%22, 2)); %0A    %7D%0A%7D

Complete ZigZag Conversion