Format code with prettier (#3375)

This commit is contained in:
acbin
2022-10-03 17:23:00 +08:00
committed by GitHub
parent 32b9b11ed5
commit e96f567bfc
464 changed files with 11483 additions and 6189 deletions

View File

@@ -1,30 +1,31 @@
package com.thealgorithms.strings.zigZagPattern;
class zigZagPattern {
public static String encode(String s, int numRows) {
if ( numRows < 2 || s.length() < numRows ) return s ;
int start = 0 , index = 0 , height = 1 , depth = numRows ;
char[] zigZagedArray = new char[ s.length() ] ;
while ( depth != 0 ) {
int pointer = start , height_space = 2 + ( ( height - 2 ) * 2 ) , depth_space = 2 + ( ( depth - 2 ) * 2 ) ;
boolean bool = true ;
while ( pointer < s.length() ) {
zigZagedArray[index++] = s.charAt( pointer ) ;
if ( height_space == 0 ) pointer += depth_space ;
else if ( depth_space == 0 ) pointer += height_space ;
else if ( bool ) {
pointer += depth_space ;
bool = false ;
if (numRows < 2 || s.length() < numRows) return s;
int start = 0, index = 0, height = 1, depth = numRows;
char[] zigZagedArray = new char[s.length()];
while (depth != 0) {
int pointer = start, height_space =
2 + ((height - 2) * 2), depth_space = 2 + ((depth - 2) * 2);
boolean bool = true;
while (pointer < s.length()) {
zigZagedArray[index++] = s.charAt(pointer);
if (height_space == 0) pointer += depth_space; else if (
depth_space == 0
) pointer += height_space; else if (bool) {
pointer += depth_space;
bool = false;
} else {
pointer += height_space ;
bool = true ;
pointer += height_space;
bool = true;
}
}
height++ ;
depth-- ;
start++ ;
height++;
depth--;
start++;
}
return new String( zigZagedArray ) ;
return new String(zigZagedArray);
}
}
}