style: include WMI_WRONG_MAP_ITERATOR (#5206)

This commit is contained in:
Piotr Idzik
2024-06-05 20:52:12 +02:00
committed by GitHub
parent 440f3ce18b
commit b315b7d578
4 changed files with 9 additions and 25 deletions

View File

@ -54,19 +54,6 @@ class AdjacencyList<E extends Comparable<E>> {
Set<E> getVertices() {
return adj.keySet();
}
/**
* Prints the adjacency list
*/
void printGraph() {
for (E vertex : adj.keySet()) {
System.out.print(vertex + " : ");
for (E adjacent : adj.get(vertex)) {
System.out.print(adjacent + " ");
}
System.out.println();
}
}
}
class TopologicalSort<E extends Comparable<E>> {
@ -104,9 +91,9 @@ class TopologicalSort<E extends Comparable<E>> {
calculateInDegree();
Queue<E> q = new LinkedList<E>();
for (E vertex : inDegree.keySet()) {
if (inDegree.get(vertex) == 0) {
q.add(vertex);
for (final var entry : inDegree.entrySet()) {
if (entry.getValue() == 0) {
q.add(entry.getKey());
}
}

View File

@ -27,9 +27,9 @@ public final class MajorityElement {
}
}
List<Integer> majorityElements = new ArrayList<>();
for (int key : numToCount.keySet()) {
if (numToCount.get(key) >= n / 2) {
majorityElements.add(key);
for (final var entry : numToCount.entrySet()) {
if (entry.getValue() >= n / 2) {
majorityElements.add(entry.getKey());
}
}
return majorityElements;

View File

@ -38,9 +38,9 @@ public final class Mode {
int max = Collections.max(count.values());
ArrayList<Integer> modes = new ArrayList<>();
for (int num : count.keySet()) {
if (count.get(num) == max) {
modes.add(num);
for (final var entry : count.entrySet()) {
if (entry.getValue() == max) {
modes.add(entry.getKey());
}
}
return modes.stream().mapToInt(n -> n).toArray();