public String convert(String s, int n) {
//corner case
if(s == null || "".equals(s) || n <= 0){
return "";
}
if(n == 1){
return s;
}
//two for loop, read
StringBuilder sb = new StringBuilder();
for(int i = 0; i < n; i++){
for(int j = i; j < s.length(); j = j + 2*n - 2){
sb.append(s.charAt(j));
if(i != 0 && i != n - 1){
int temp = (j + 2*n -2) - 2*i;//-2 * i
if(temp < s.length()){
sb.append(s.charAt(temp));
}
}
}
}
return sb.toString();
}