style: enable HideUtilityClassConstructor in checkstyle (#5147)

This commit is contained in:
Piotr Idzik
2024-05-08 08:58:29 +02:00
committed by GitHub
parent 030bb91d05
commit d3bb691f59
285 changed files with 895 additions and 339 deletions

View File

@ -9,7 +9,9 @@ import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
public class A_Star {
public final class A_Star {
private A_Star() {
}
private static class Graph {

View File

@ -14,7 +14,9 @@ import java.util.Arrays;
*
* Output : YES
*/
public class BipartiteGrapfDFS {
public final class BipartiteGrapfDFS {
private BipartiteGrapfDFS() {
}
private static boolean bipartite(int V, ArrayList<ArrayList<Integer>> adj, int[] color, int node) {
if (color[node] == -1) {

View File

@ -107,7 +107,9 @@ class Graph<E extends Comparable<E>> {
}
}
public class ConnectedComponent {
public final class ConnectedComponent {
private ConnectedComponent() {
}
public static void main(String[] args) {
Graph<Character> graphChars = new Graph<>();

View File

@ -78,7 +78,9 @@ class Cycle {
}
}
public class Cycles {
public final class Cycles {
private Cycles() {
}
public static void main(String[] args) {
Cycle c = new Cycle();

View File

@ -120,7 +120,9 @@ class AdjacencyListGraph<E extends Comparable<E>> {
}
}
public class Graphs {
public final class Graphs {
private Graphs() {
}
public static void main(String[] args) {
AdjacencyListGraph<Integer> graph = new AdjacencyListGraph<>();

View File

@ -130,7 +130,9 @@ class TopologicalSort<E extends Comparable<E>> {
/**
* A driver class that sorts a given graph in topological order.
*/
public class KahnsAlgorithm {
public final class KahnsAlgorithm {
private KahnsAlgorithm() {
}
public static void main(String[] args) {
// Graph definition and initialization

View File

@ -12,7 +12,9 @@ import java.util.Queue;
*
* @author Unknown
*/
public class MatrixGraphs {
public final class MatrixGraphs {
private MatrixGraphs() {
}
public static void main(String[] args) {
AdjacencyMatrixGraph graph = new AdjacencyMatrixGraph(10);

View File

@ -2,7 +2,9 @@ package com.thealgorithms.datastructures.hashmap.hashing;
import java.util.Scanner;
public class Main {
public final class Main {
private Main() {
}
public static void main(String[] args) {
int choice, key;

View File

@ -2,7 +2,9 @@ package com.thealgorithms.datastructures.hashmap.hashing;
import java.util.Scanner;
public class MainCuckooHashing {
public final class MainCuckooHashing {
private MainCuckooHashing() {
}
public static void main(String[] args) {
int choice, key;

View File

@ -8,7 +8,9 @@ This class finds the majority element(s) in an array of integers.
A majority element is an element that appears more than or equal to n/2 times, where n is the length
of the array.
*/
public class MajorityElement {
public final class MajorityElement {
private MajorityElement() {
}
/*
This method returns the majority element(s) in the given array of integers.
@param nums: an array of integers

View File

@ -2,7 +2,9 @@ package com.thealgorithms.datastructures.lists;
import java.util.Scanner;
public class CreateAndDetectLoop {
public final class CreateAndDetectLoop {
private CreateAndDetectLoop() {
}
/**
* Prints the linked list.

View File

@ -6,7 +6,9 @@ import java.util.List;
/**
* @author https://github.com/shellhub
*/
public class MergeSortedArrayList {
public final class MergeSortedArrayList {
private MergeSortedArrayList() {
}
public static void main(String[] args) {
List<Integer> listA = new ArrayList<>();

View File

@ -152,7 +152,9 @@ class Queue {
*
* @author Unknown
*/
public class Queues {
public final class Queues {
private Queues() {
}
/**
* Main method

View File

@ -8,7 +8,9 @@ import java.util.Stack;
*
* @author Ishika Agarwal, 2021
*/
public class ReverseStack {
public final class ReverseStack {
private ReverseStack() {
}
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {

View File

@ -6,7 +6,9 @@ import java.util.NoSuchElementException;
* @author Varun Upadhyay (https://github.com/varunu28)
*/
// An implementation of a Stack using a Linked List
class StackOfLinkedList {
final class StackOfLinkedList {
private StackOfLinkedList() {
}
public static void main(String[] args) {
LinkedListStack stack = new LinkedListStack();

View File

@ -9,7 +9,9 @@ import com.thealgorithms.datastructures.trees.BinaryTree.Node;
* left half recursively to create left subtree 3. Use the right half
* recursively to create right subtree
*/
public class BSTFromSortedArray {
public final class BSTFromSortedArray {
private BSTFromSortedArray() {
}
public static Node createBST(int[] array) {
if (array == null || array.length == 0) {
return null;

View File

@ -42,7 +42,9 @@ import com.thealgorithms.datastructures.trees.BinaryTree.Node;
* subtree. If left subtree returns a non-null value then that will be ceil
* otherwise the root is ceil
*/
public class CeilInBinarySearchTree {
public final class CeilInBinarySearchTree {
private CeilInBinarySearchTree() {
}
public static Node getCeil(Node root, int key) {
if (root == null) {

View File

@ -8,7 +8,9 @@ package com.thealgorithms.datastructures.trees;
* where 'min' and 'max' values represent the child nodes (left, right).
* 2. The smallest possible node value is Integer.MIN_VALUE, the biggest - Integer.MAX_VALUE.
*/
public class CheckBinaryTreeIsValidBST {
public final class CheckBinaryTreeIsValidBST {
private CheckBinaryTreeIsValidBST() {
}
public static boolean isBST(BinaryTree.Node root) {
return isBSTUtil(root, Integer.MIN_VALUE, Integer.MAX_VALUE);
}

View File

@ -14,7 +14,9 @@ import java.util.Stack;
*
* @author [Ian Cowan](<a href="https://github.com/iccowan">Git-Ian Cowan</a>)
*/
public class CheckIfBinaryTreeBalanced {
public final class CheckIfBinaryTreeBalanced {
private CheckIfBinaryTreeBalanced() {
}
/**
* Recursive is BT balanced implementation
*

View File

@ -30,7 +30,9 @@ import com.thealgorithms.datastructures.trees.BinaryTree.Node;
*
* @author kumanoit on 10/10/22 IST 12:52 AM
*/
public class CheckTreeIsSymmetric {
public final class CheckTreeIsSymmetric {
private CheckTreeIsSymmetric() {
}
public static boolean isSymmetric(Node root) {
if (root == null) {

View File

@ -17,7 +17,9 @@ import java.util.Map;
* Complexity: Time: O(n) hashmap reduced iteration to find index in inorder
* array Space: O(n) space taken by hashmap
*/
public class CreateBinaryTreeFromInorderPreorder {
public final class CreateBinaryTreeFromInorderPreorder {
private CreateBinaryTreeFromInorderPreorder() {
}
public static Node createTree(final Integer[] preorder, final Integer[] inorder) {
if (preorder == null || inorder == null) {
return null;

View File

@ -25,7 +25,9 @@ import java.util.List;
*
* @author Albina Gimaletdinova on 21/02/2023
*/
public class InorderTraversal {
public final class InorderTraversal {
private InorderTraversal() {
}
public static List<Integer> recursiveInorder(BinaryTree.Node root) {
List<Integer> result = new ArrayList<>();
recursiveInorder(root, result);

View File

@ -3,7 +3,9 @@ package com.thealgorithms.datastructures.trees;
import java.util.ArrayList;
import java.util.Scanner;
public class LCA {
public final class LCA {
private LCA() {
}
private static final Scanner SCANNER = new Scanner(System.in);

View File

@ -5,7 +5,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
public class LevelOrderTraversal {
public final class LevelOrderTraversal {
private LevelOrderTraversal() {
}
public static List<List<Integer>> traverse(BinaryTree.Node root) {
if (root == null) {

View File

@ -26,7 +26,9 @@ import java.util.List;
*
* @author Albina Gimaletdinova on 21/02/2023
*/
public class PostOrderTraversal {
public final class PostOrderTraversal {
private PostOrderTraversal() {
}
public static List<Integer> recursivePostOrder(BinaryTree.Node root) {
List<Integer> result = new ArrayList<>();
recursivePostOrder(root, result);

View File

@ -25,7 +25,9 @@ import java.util.List;
*
* @author Albina Gimaletdinova on 17/02/2023
*/
public class PreOrderTraversal {
public final class PreOrderTraversal {
private PreOrderTraversal() {
}
public static List<Integer> recursivePreOrder(BinaryTree.Node root) {
List<Integer> result = new ArrayList<>();
recursivePreOrder(root, result);

View File

@ -87,7 +87,9 @@ class Tree {
}
// Driver class to test above methods
public class PrintTopViewofTree {
public final class PrintTopViewofTree {
private PrintTopViewofTree() {
}
public static void main(String[] args) {
/* Create following Binary Tree

View File

@ -32,7 +32,9 @@ import java.util.Deque;
*
* @author Albina Gimaletdinova on 13/01/2023
*/
public class SameTreesCheck {
public final class SameTreesCheck {
private SameTreesCheck() {
}
public static boolean check(BinaryTree.Node p, BinaryTree.Node q) {
if (p == null && q == null) {
return true;

View File

@ -20,7 +20,9 @@ in a tree from top to bottom and left to right, so for a tree :
the sequence will be :
4 2 7 1 5 9 3 8 6 10
*/
public class VerticalOrderTraversal {
public final class VerticalOrderTraversal {
private VerticalOrderTraversal() {
}
/*Function that receives a root Node and prints the tree
in Vertical Order.*/

View File

@ -34,7 +34,9 @@ import java.util.List;
*
* @author Albina Gimaletdinova on 11/01/2023
*/
public class ZigzagTraversal {
public final class ZigzagTraversal {
private ZigzagTraversal() {
}
public static List<List<Integer>> traverse(BinaryTree.Node root) {
if (root == null) {
return List.of();

View File

@ -3,7 +3,9 @@ package com.thealgorithms.datastructures.trees;
import java.util.Scanner;
import java.util.concurrent.ThreadLocalRandom;
class Main {
final class NearestRightKey {
private NearestRightKey() {
}
public static void main(String[] args) {
NRKTree root = BuildTree();