diff --git a/src/main/java/com/thealgorithms/backtracking/MColoring.java b/src/main/java/com/thealgorithms/backtracking/MColoring.java index c9bc0200..93b17941 100644 --- a/src/main/java/com/thealgorithms/backtracking/MColoring.java +++ b/src/main/java/com/thealgorithms/backtracking/MColoring.java @@ -1,6 +1,5 @@ package com.thealgorithms.backtracking; -import java.io.*; import java.util.*; /** diff --git a/src/main/java/com/thealgorithms/datastructures/dynamicarray/DynamicArray.java b/src/main/java/com/thealgorithms/datastructures/dynamicarray/DynamicArray.java index fb778357..f6f0276e 100644 --- a/src/main/java/com/thealgorithms/datastructures/dynamicarray/DynamicArray.java +++ b/src/main/java/com/thealgorithms/datastructures/dynamicarray/DynamicArray.java @@ -145,7 +145,7 @@ public class DynamicArray implements Iterable { * @return Iterator a Dynamic Array Iterator */ @Override - public Iterator iterator() { + public Iterator iterator() { return new DynamicArrayIterator(); } diff --git a/src/main/java/com/thealgorithms/datastructures/lists/CircleLinkedList.java b/src/main/java/com/thealgorithms/datastructures/lists/CircleLinkedList.java index 5d9f0b3a..c42b1045 100644 --- a/src/main/java/com/thealgorithms/datastructures/lists/CircleLinkedList.java +++ b/src/main/java/com/thealgorithms/datastructures/lists/CircleLinkedList.java @@ -53,7 +53,7 @@ public class CircleLinkedList { // utility function for traversing the list public String toString() { - Node p = head.next; + Node p = head.next; String s = "[ "; while (p != head) { s += p.value; @@ -91,7 +91,7 @@ public class CircleLinkedList { } public static void main(String[] args) { - CircleLinkedList cl = new CircleLinkedList(); + CircleLinkedList cl = new CircleLinkedList<>(); cl.append(12); System.out.println(cl); cl.append(23); diff --git a/src/main/java/com/thealgorithms/datastructures/lists/CursorLinkedList.java b/src/main/java/com/thealgorithms/datastructures/lists/CursorLinkedList.java index cefc47c2..22399bd6 100644 --- a/src/main/java/com/thealgorithms/datastructures/lists/CursorLinkedList.java +++ b/src/main/java/com/thealgorithms/datastructures/lists/CursorLinkedList.java @@ -134,7 +134,7 @@ public class CursorLinkedList { } private void free(int index) { - Node os_node = cursorSpace[os]; + Node os_node = cursorSpace[os]; int os_next = os_node.next; cursorSpace[os].next = index; cursorSpace[index].element = null; diff --git a/src/main/java/com/thealgorithms/misc/ThreeSumProblem.java b/src/main/java/com/thealgorithms/misc/ThreeSumProblem.java index 1b72996d..a232ad98 100644 --- a/src/main/java/com/thealgorithms/misc/ThreeSumProblem.java +++ b/src/main/java/com/thealgorithms/misc/ThreeSumProblem.java @@ -75,7 +75,7 @@ public class ThreeSumProblem { public List> Hashmap(int[] nums, int target) { Arrays.sort(nums); - Set> ts = new HashSet(); + Set> ts = new HashSet<>(); HashMap hm = new HashMap<>(); for (int i = 0; i < nums.length; i++) { @@ -94,6 +94,6 @@ public class ThreeSumProblem { } } } - return new ArrayList(ts); + return new ArrayList<>(ts); } } diff --git a/src/main/java/com/thealgorithms/searches/UnionFind.java b/src/main/java/com/thealgorithms/searches/UnionFind.java index d32e4fd3..4dfece0e 100644 --- a/src/main/java/com/thealgorithms/searches/UnionFind.java +++ b/src/main/java/com/thealgorithms/searches/UnionFind.java @@ -45,7 +45,7 @@ public class UnionFind { } public int count() { - List parents = new ArrayList(); + List parents = new ArrayList<>(); for (int i = 0; i < p.length; i++) { if (!parents.contains(find(i))) { parents.add(find(i)); diff --git a/src/main/java/com/thealgorithms/strings/WordLadder.java b/src/main/java/com/thealgorithms/strings/WordLadder.java index a4634ce0..e88acbd1 100644 --- a/src/main/java/com/thealgorithms/strings/WordLadder.java +++ b/src/main/java/com/thealgorithms/strings/WordLadder.java @@ -51,13 +51,13 @@ class WordLadder { * if the endword is there. Otherwise, will return the length as 0. */ public static int ladderLength(String beginWord, String endWord, List wordList) { - HashSet set = new HashSet(wordList); + HashSet set = new HashSet<>(wordList); if (!set.contains(endWord)) { return 0; } - Queue queue = new LinkedList(); + Queue queue = new LinkedList<>(); queue.offer(beginWord); int level = 1;