mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-23 04:20:16 +08:00
style: enable LocalVariableName
in CheckStyle (#5191)
* style: enable LocalVariableName in checkstyle * Removed minor bug * Resolved Method Name Bug * Changed names according to suggestions
This commit is contained in:
@ -8,13 +8,13 @@ public final class MyAtoi {
|
||||
}
|
||||
public static int myAtoi(String s) {
|
||||
s = s.trim();
|
||||
char[] char_1 = s.toCharArray();
|
||||
char[] char1 = s.toCharArray();
|
||||
String number = "";
|
||||
boolean negative = false;
|
||||
boolean zero = false;
|
||||
boolean isDigit = false;
|
||||
|
||||
for (char ch : char_1) {
|
||||
for (char ch : char1) {
|
||||
if (Character.isDigit(ch)) {
|
||||
if (number.length() > 1 && !isDigit) {
|
||||
number = "0";
|
||||
|
@ -67,24 +67,24 @@ final class WordLadder {
|
||||
int size = queue.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
String curr = queue.poll();
|
||||
char[] words_chars = curr.toCharArray();
|
||||
for (int j = 0; j < words_chars.length; j++) {
|
||||
char original_chars = words_chars[j];
|
||||
char[] wordsChars = curr.toCharArray();
|
||||
for (int j = 0; j < wordsChars.length; j++) {
|
||||
char originalChars = wordsChars[j];
|
||||
for (char c = 'a'; c <= 'z'; c++) {
|
||||
if (words_chars[j] == c) {
|
||||
if (wordsChars[j] == c) {
|
||||
continue;
|
||||
}
|
||||
words_chars[j] = c;
|
||||
String new_word = String.valueOf(words_chars);
|
||||
if (new_word.equals(endWord)) {
|
||||
wordsChars[j] = c;
|
||||
String newWord = String.valueOf(wordsChars);
|
||||
if (newWord.equals(endWord)) {
|
||||
return level + 1;
|
||||
}
|
||||
if (set.contains(new_word)) {
|
||||
set.remove(new_word);
|
||||
queue.offer(new_word);
|
||||
if (set.contains(newWord)) {
|
||||
set.remove(newWord);
|
||||
queue.offer(newWord);
|
||||
}
|
||||
}
|
||||
words_chars[j] = original_chars;
|
||||
wordsChars[j] = originalChars;
|
||||
}
|
||||
}
|
||||
level++;
|
||||
|
@ -13,20 +13,20 @@ final class zigZagPattern {
|
||||
char[] zigZagedArray = new char[s.length()];
|
||||
while (depth != 0) {
|
||||
int pointer = start;
|
||||
int height_space = 2 + ((height - 2) * 2);
|
||||
int depth_space = 2 + ((depth - 2) * 2);
|
||||
int heightSpace = 2 + ((height - 2) * 2);
|
||||
int depthSpace = 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;
|
||||
if (heightSpace == 0)
|
||||
pointer += depthSpace;
|
||||
else if (depthSpace == 0)
|
||||
pointer += heightSpace;
|
||||
else if (bool) {
|
||||
pointer += depth_space;
|
||||
pointer += depthSpace;
|
||||
bool = false;
|
||||
} else {
|
||||
pointer += height_space;
|
||||
pointer += heightSpace;
|
||||
bool = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user