Initial commit

This commit is contained in:
Arkaprabha Chakraborty
2022-07-26 16:15:18 +05:30
commit cef4c4dcc4
65 changed files with 1806 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
class Solution {
public String convert(String str, int rows) {
String[] zigzag = new String[rows];
for (int i = 0; i < rows; i++)
zigzag[i] = "";
for (int i = 0, j = 0, k = 0; i < str.length(); i++) {
zigzag[j] += str.charAt(i);
if (j == rows - 1)
k = 1;
if (j == 0)
k = 0;
if (k == 1 && j > 0)
j--;
if (k == 0 && j < rows - 1)
j++;
}
String ret = "";
for (int i = 0; i < rows; i++)
ret += zigzag[i];
return ret;
}
}