It is time-complexity O(n+l) and space -complexity O(n)

```
public class Solution {
public String convert(String s, int nRows) {
if (s==null||s.length()==0||nRows<=1) return s;
String[] array= new String[nRows];
for (int i=0;i<nRows;i++)
array[i]="";
for (int i=0;i<s.length();i++){
int position = i%(2*nRows-2);
if (position<nRows)
array[position]=new StringBuilder(array[position]).append(s.charAt(i)).toString();
else
array[2*nRows-2-position]=new StringBuilder(array[2*nRows-2-position]).append(s.charAt(i)).toString();
}
for (int i=1;i<nRows;i++)
array[0]= new StringBuilder(array[0]).append(array[i]).toString();
return array[0];
}
```

}