Skip to content

Commit cafea1e

Browse files
Refactored Identifiers (#5306)
Co-authored-by: Bama Charan Chhandogi <[email protected]>
1 parent 6e23e19 commit cafea1e

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/main/java/com/thealgorithms/misc/TwoSumProblem.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ private TwoSumProblem() {
2020
public static Optional<Pair<Integer, Integer>> twoSum(final int[] values, final int target) {
2121
HashMap<Integer, Integer> valueToIndex = new HashMap<>();
2222
for (int i = 0; i < values.length; i++) {
23-
final var rem = target - values[i];
24-
if (valueToIndex.containsKey(rem)) {
25-
return Optional.of(Pair.of(valueToIndex.get(rem), i));
23+
final var remainder = target - values[i];
24+
if (valueToIndex.containsKey(remainder)) {
25+
return Optional.of(Pair.of(valueToIndex.get(remainder), i));
2626
}
2727
if (!valueToIndex.containsKey(values[i])) {
2828
valueToIndex.put(values[i], i);

src/main/java/com/thealgorithms/searches/FibonacciSearch.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ public static void main(String[] args) {
6262
Integer[] integers = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
6363

6464
int size = integers.length;
65-
Integer shouldBeFound = 128;
65+
Integer targetValue = 128;
6666
FibonacciSearch fsearch = new FibonacciSearch();
67-
int atIndex = fsearch.find(integers, shouldBeFound);
67+
int atIndex = fsearch.find(integers, targetValue);
6868

69-
System.out.println("Should be found: " + shouldBeFound + ". Found " + integers[atIndex] + " at index " + atIndex + ". An array length " + size);
69+
System.out.println("Should be found: " + targetValue + ". Found " + integers[atIndex] + " at index " + atIndex + ". An array length " + size);
7070
}
7171
}

src/main/java/com/thealgorithms/strings/WordLadder.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ public static int ladderLength(String beginWord, String endWord, List<String> wo
7575
continue;
7676
}
7777
wordsChars[j] = c;
78-
String newWord = String.valueOf(wordsChars);
79-
if (newWord.equals(endWord)) {
78+
String transformedWord = String.valueOf(wordsChars);
79+
if (transformedWord.equals(endWord)) {
8080
return level + 1;
8181
}
82-
if (set.contains(newWord)) {
83-
set.remove(newWord);
84-
queue.offer(newWord);
82+
if (set.contains(transformedWord)) {
83+
set.remove(transformedWord);
84+
queue.offer(transformedWord);
8585
}
8686
}
8787
wordsChars[j] = originalChars;

0 commit comments

Comments
 (0)