@@ -0,0 +1,1651 @@
+// 6. ZigZag Conversion%0A/**%0A * The string %22PAYPALISHIRING%22 is written in a zigzag pattern on a given number of rows like this: %0A * (you may want to display this pattern in a fixed font for better legibility)%0A * %0A * P   A   H   N%0A * A P L S I I G%0A * Y   I   R%0A * %0A * And then read line by line: %22PAHNAPLSIIGYIR%22%0A * Write the code that will take a string and make this conversion given a number of rows:%0A * %0A * string convert(string text, int nRows);%0A * %0A * convert(%22PAYPALISHIRING%22, 3) should return %22PAHNAPLSIIGYIR%22.%0A * %0A * Tags: String%0A * %0A * Author: Xinyue Zhang%0A */%0A%0Apublic class Solution %7B%0A    public String convert(String s, int nRows) %7B%0A        if (s == null %7C%7C s.isEmpty()) %7B%0A            return s;%0A        %7D%0A%0A        int length = s.length();%0A        if (length %3C= nRows %7C%7C nRows %3C= 1) %7B%0A            return s;%0A        %7D%0A%0A        StringBuilder sb = new StringBuilder();%0A%0A        int step = 2 * (nRows - 1);%0A        int count = 0;%0A%0A        for (int i = 0; i %3C nRows; i++)%7B%0A            int interval = step - 2 * i;%0A%0A            for (int j = i; j %3C length; j += step)%7B%0A                   sb.append(s.charAt(j));%0A                count++;%0A                if (interval %3E 0 && interval %3C step %0A                    && j + interval %3C length %0A                    && count %3C  length) %7B%0A                    sb.append(s.charAt(j + interval));%0A                    count++;%0A                %7D%0A            %7D%0A        %7D%0A        return sb.toString();  %0A    %7D%0A    %0A    public static void main(String args%5B%5D) %7B%0A        String s = %22PAYPALISHIRING%22;%0A        Solution sol = new Solution();%0A        String res = sol.convert(s, 3);%0A        System.out.println(res);%0A    %7D%0A%7D%0A

Add solution for 6. ZigZag Conversion