Hi,

I tried the below code for the ZigZag conversion. I feel that it runs with O(n) complexity. Still I get time limit exceeding. Is there a O(logn) or better solution? Any suggestions?

```
public String convert(String s, int nRows) {
if (nRows == 1) return s;
Character [][] chararray = new Character[nRows][1000];
String retString = "";
int len = 0;
int i = 0,j = 0;
while(len < s.length()){
if(len >= s.length()){
break;
}
chararray[i][j] = s.charAt(len);
i++;
len++;
if(i == nRows){
i--;
while(i > 0){
if(len >= s.length()){
break;
}
i--;
j++;
chararray[i][j] = s.charAt(len);
len++;
}
i++;
}
}
for(int k = 0 ; k < nRows; k++){
for(int l = 0; l <= j; l++){
if(chararray[k][l] != null){
retString += chararray[k][l];
}
}
}
return retString;
}
```