mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-22 03:24:57 +08:00
style: enable HideUtilityClassConstructor
in checkstyle (#5147)
This commit is contained in:
@ -25,7 +25,9 @@ int n=10;
|
||||
|
||||
|
||||
*/
|
||||
public class BoardPath {
|
||||
public final class BoardPath {
|
||||
private BoardPath() {
|
||||
}
|
||||
|
||||
public static long startTime;
|
||||
public static long endTime;
|
||||
|
@ -4,7 +4,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
* Java program for Boundary fill algorithm.
|
||||
* @author Akshay Dubey (https://github.com/itsAkshayDubey)
|
||||
*/
|
||||
public class BoundaryFill {
|
||||
public final class BoundaryFill {
|
||||
private BoundaryFill() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color at the given co-odrinates of a 2D image
|
||||
|
@ -2,7 +2,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
/* A Naive recursive implementation
|
||||
of 0-1 Knapsack problem */
|
||||
public class BruteForceKnapsack {
|
||||
public final class BruteForceKnapsack {
|
||||
private BruteForceKnapsack() {
|
||||
}
|
||||
// Returns the maximum value that
|
||||
// can be put in a knapsack of
|
||||
// capacity W
|
||||
|
@ -10,7 +10,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
*/
|
||||
import java.util.Scanner;
|
||||
|
||||
public class CatalanNumber {
|
||||
public final class CatalanNumber {
|
||||
private CatalanNumber() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method finds the nth Catalan number
|
||||
|
@ -5,7 +5,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
Link : https://medium.com/analytics-vidhya/leetcode-q70-climbing-stairs-easy-444a4aae54e8
|
||||
*/
|
||||
public class ClimbingStairs {
|
||||
public final class ClimbingStairs {
|
||||
private ClimbingStairs() {
|
||||
}
|
||||
|
||||
public static int numberOfWays(int n) {
|
||||
|
||||
|
@ -3,7 +3,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
/**
|
||||
* @author Varun Upadhyay (https://github.com/varunu28)
|
||||
*/
|
||||
public class CoinChange {
|
||||
public final class CoinChange {
|
||||
private CoinChange() {
|
||||
}
|
||||
|
||||
// Driver Program
|
||||
public static void main(String[] args) {
|
||||
|
@ -15,7 +15,9 @@
|
||||
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
public class CountFriendsPairing {
|
||||
public final class CountFriendsPairing {
|
||||
private CountFriendsPairing() {
|
||||
}
|
||||
|
||||
public static boolean countFriendsPairing(int n, int[] a) {
|
||||
int[] dp = new int[n + 1];
|
||||
|
@ -13,7 +13,9 @@ Following is implementation of Dynamic Programming approach. */
|
||||
// Code ---->
|
||||
// Java program to find number of ways to get sum 'x' with 'n'
|
||||
// dice where every dice has 'm' faces
|
||||
class DP {
|
||||
final class DP {
|
||||
private DP() {
|
||||
}
|
||||
|
||||
/* The main function that returns the number of ways to get sum 'x' with 'n' dice and 'm' with m
|
||||
* faces. */
|
||||
|
@ -24,7 +24,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
*/
|
||||
import java.util.Scanner;
|
||||
|
||||
public class EditDistance {
|
||||
public final class EditDistance {
|
||||
private EditDistance() {
|
||||
}
|
||||
|
||||
public static int minDistance(String word1, String word2) {
|
||||
int len1 = word1.length();
|
||||
|
@ -3,7 +3,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
/**
|
||||
* DynamicProgramming solution for the Egg Dropping Puzzle
|
||||
*/
|
||||
public class EggDropping {
|
||||
public final class EggDropping {
|
||||
private EggDropping() {
|
||||
}
|
||||
|
||||
// min trials with n eggs and m floors
|
||||
public static int minTrials(int n, int m) {
|
||||
|
@ -7,7 +7,9 @@ import java.util.Scanner;
|
||||
/**
|
||||
* @author Varun Upadhyay (https://github.com/varunu28)
|
||||
*/
|
||||
public class Fibonacci {
|
||||
public final class Fibonacci {
|
||||
private Fibonacci() {
|
||||
}
|
||||
|
||||
private static final Map<Integer, Integer> CACHE = new HashMap<>();
|
||||
|
||||
|
@ -4,7 +4,9 @@ import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.Vector;
|
||||
|
||||
public class FordFulkerson {
|
||||
public final class FordFulkerson {
|
||||
private FordFulkerson() {
|
||||
}
|
||||
|
||||
static final int INF = 987654321;
|
||||
// edges
|
||||
|
@ -6,7 +6,9 @@
|
||||
/** Program description - To find the maximum subarray sum */
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
public class KadaneAlgorithm {
|
||||
public final class KadaneAlgorithm {
|
||||
private KadaneAlgorithm() {
|
||||
}
|
||||
|
||||
public static boolean max_Sum(int[] a, int predicted_answer) {
|
||||
int sum = a[0], running_sum = 0;
|
||||
|
@ -11,7 +11,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
x1 < x2 > x3 < x4 > x5 < …. xn or
|
||||
x1 > x2 < x3 > x4 < x5 > …. xn
|
||||
*/
|
||||
public class LongestAlternatingSubsequence {
|
||||
public final class LongestAlternatingSubsequence {
|
||||
private LongestAlternatingSubsequence() {
|
||||
}
|
||||
|
||||
/* Function to return longest alternating subsequence length*/
|
||||
static int AlternatingLength(int[] arr, int n) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
class LongestCommonSubsequence {
|
||||
final class LongestCommonSubsequence {
|
||||
private LongestCommonSubsequence() {
|
||||
}
|
||||
|
||||
public static String getLCS(String str1, String str2) {
|
||||
// At least one string is null
|
||||
|
@ -5,7 +5,9 @@ import java.util.Scanner;
|
||||
/**
|
||||
* @author Afrizal Fikri (https://github.com/icalF)
|
||||
*/
|
||||
public class LongestIncreasingSubsequence {
|
||||
public final class LongestIncreasingSubsequence {
|
||||
private LongestIncreasingSubsequence() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
|
@ -4,7 +4,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
* Algorithm explanation
|
||||
* https://www.educative.io/edpresso/longest-palindromic-subsequence-algorithm
|
||||
*/
|
||||
public class LongestPalindromicSubsequence {
|
||||
public final class LongestPalindromicSubsequence {
|
||||
private LongestPalindromicSubsequence() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String a = "BBABCBCAB";
|
||||
|
@ -3,7 +3,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
/*
|
||||
* Algorithm explanation https://leetcode.com/problems/longest-palindromic-substring/
|
||||
*/
|
||||
public class LongestPalindromicSubstring {
|
||||
public final class LongestPalindromicSubstring {
|
||||
private LongestPalindromicSubstring() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String a = "babad";
|
||||
|
@ -7,7 +7,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
* @author Libin Yang (https://github.com/yanglbme)
|
||||
* @since 2018/10/5
|
||||
*/
|
||||
public class LongestValidParentheses {
|
||||
public final class LongestValidParentheses {
|
||||
private LongestValidParentheses() {
|
||||
}
|
||||
|
||||
public static int getLongestValidParentheses(String s) {
|
||||
if (s == null || s.length() < 2) {
|
||||
|
@ -4,7 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class MatrixChainMultiplication {
|
||||
public final class MatrixChainMultiplication {
|
||||
private MatrixChainMultiplication() {
|
||||
}
|
||||
|
||||
private static final Scanner SCANNER = new Scanner(System.in);
|
||||
private static final ArrayList<Matrix> MATRICES = new ArrayList<>();
|
||||
|
@ -6,7 +6,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
// matrix Ai has dimension pi−1 ×pi
|
||||
// , fully parenthesize the product A1A2 ···An in a way that
|
||||
// minimizes the number of scalar multiplications.
|
||||
public class MatrixChainRecursiveTopDownMemoisation {
|
||||
public final class MatrixChainRecursiveTopDownMemoisation {
|
||||
private MatrixChainRecursiveTopDownMemoisation() {
|
||||
}
|
||||
|
||||
static int Memoized_Matrix_Chain(int[] p) {
|
||||
int n = p.length;
|
||||
|
@ -8,7 +8,9 @@
|
||||
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
public class NewManShanksPrime {
|
||||
public final class NewManShanksPrime {
|
||||
private NewManShanksPrime() {
|
||||
}
|
||||
|
||||
public static boolean nthManShanksPrime(int n, int expected_answer) {
|
||||
int[] a = new int[n + 1];
|
||||
|
@ -17,7 +17,9 @@ import java.util.Scanner;
|
||||
* "aba | b | bbabb | ababa"
|
||||
* @author [Syed] (https://github.com/roeticvampire)
|
||||
*/
|
||||
public class PalindromicPartitioning {
|
||||
public final class PalindromicPartitioning {
|
||||
private PalindromicPartitioning() {
|
||||
}
|
||||
|
||||
public static int minimalpartitions(String word) {
|
||||
int len = word.length();
|
||||
|
@ -18,7 +18,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class PartitionProblem {
|
||||
public final class PartitionProblem {
|
||||
private PartitionProblem() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a set of integers can be partitioned into two subsets such that the sum of elements
|
||||
|
@ -12,7 +12,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
* length of pat
|
||||
*
|
||||
*/
|
||||
public class RegexMatching {
|
||||
public final class RegexMatching {
|
||||
private RegexMatching() {
|
||||
}
|
||||
|
||||
// Method 1: Using Recursion
|
||||
// Time Complexity=0(2^(N+M)) Space Complexity=Recursion Extra Space
|
||||
|
@ -4,7 +4,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
* A Dynamic Programming solution for the Rod cutting problem.
|
||||
* Returns the best obtainable price for a rod of length n and price[] as prices of different pieces.
|
||||
*/
|
||||
public class RodCutting {
|
||||
public final class RodCutting {
|
||||
private RodCutting() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method calculates the maximum obtainable value for cutting a rod of length n
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
// Java program to find length of the shortest supersequence
|
||||
class ShortestSuperSequence {
|
||||
final class ShortestSuperSequence {
|
||||
private ShortestSuperSequence() {
|
||||
}
|
||||
|
||||
// Function to find length of the
|
||||
// shortest supersequence of X and Y.
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
public class SubsetSum {
|
||||
public final class SubsetSum {
|
||||
private SubsetSum() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Driver Code
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
public class SumOfSubset {
|
||||
public final class SumOfSubset {
|
||||
private SumOfSubset() {
|
||||
}
|
||||
|
||||
public static boolean subsetSum(int[] arr, int num, int Key) {
|
||||
if (Key == 0) {
|
||||
|
@ -4,7 +4,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
* The {@code Tribonacci} class provides a method to compute the n-th number in the Tribonacci sequence.
|
||||
* N-th Tribonacci Number - https://leetcode.com/problems/n-th-tribonacci-number/description/
|
||||
*/
|
||||
public class Tribonacci {
|
||||
public final class Tribonacci {
|
||||
private Tribonacci() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the n-th Tribonacci number.
|
||||
|
@ -14,7 +14,9 @@
|
||||
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
public class WildcardMatching {
|
||||
public final class WildcardMatching {
|
||||
private WildcardMatching() {
|
||||
}
|
||||
|
||||
public static boolean isMatch(String text, String pattern) {
|
||||
int m = text.length();
|
||||
|
@ -10,7 +10,9 @@ package com.thealgorithms.dynamicprogramming;
|
||||
* shelf. You are not allowed to reorder. You have to find the maximum profit
|
||||
*
|
||||
*/
|
||||
public class WineProblem {
|
||||
public final class WineProblem {
|
||||
private WineProblem() {
|
||||
}
|
||||
|
||||
// Method 1: Using Recursion
|
||||
// Time Complexity=0(2^N) Space Complexity=Recursion extra space
|
||||
|
Reference in New Issue
Block a user