public String convert(String s, int numRows) {
        if(s.isEmpty()) {
            return "";
        }
        if(s.length() <= numRows) {
            return s;
        }
        if(numRows == 1) {
            return s;
        }

        StringBuilder sb = new StringBuilder(s.length());

        for(int i = 0; i < numRows; i++) {
            int j = i;
            while (j < s.length()) {
                sb.append(s.charAt(j));
                int nextJ = j + numRows + (numRows - 2);
                int mid = nextJ - (i + 1) - (i - 1);
                if(mid < s.length() && mid > j && mid < nextJ) {
                    sb.append(s.charAt(mid));
                }
                j = nextJ;
            }
        }

        return sb.toString();
    }