mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-23 04:20:16 +08:00
style: enable HideUtilityClassConstructor
in checkstyle (#5147)
This commit is contained in:
@ -5,7 +5,9 @@ package com.thealgorithms.strings;
|
||||
* based on the position of the characters in the conventional ordering of an
|
||||
* alphabet. Wikipedia: https://en.wikipedia.org/wiki/Alphabetical_order
|
||||
*/
|
||||
class Alphabetical {
|
||||
final class Alphabetical {
|
||||
private Alphabetical() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
assert !isAlphabetical("123abc");
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
public class CharactersSame {
|
||||
public final class CharactersSame {
|
||||
private CharactersSame() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Driver Code
|
||||
|
@ -7,7 +7,9 @@ import java.util.Map;
|
||||
* Two strings are anagrams if they are made of the same letters arranged
|
||||
* differently (ignoring the case).
|
||||
*/
|
||||
public class CheckAnagrams {
|
||||
public final class CheckAnagrams {
|
||||
private CheckAnagrams() {
|
||||
}
|
||||
/**
|
||||
* Check if two strings are anagrams or not
|
||||
*
|
||||
|
@ -9,7 +9,9 @@ import java.util.Set;
|
||||
* on the position of the characters in the conventional ordering of an
|
||||
* alphabet. Wikipedia: https://en.wikipedia.org/wiki/Alphabetical_order
|
||||
*/
|
||||
public class CheckVowels {
|
||||
public final class CheckVowels {
|
||||
private CheckVowels() {
|
||||
}
|
||||
|
||||
private static final Set<Character> VOWELS = new HashSet<>(Arrays.asList('a', 'e', 'i', 'o', 'u'));
|
||||
|
||||
|
@ -4,7 +4,9 @@ package com.thealgorithms.strings;
|
||||
is the number of positions at which the corresponding symbols are different.
|
||||
https://en.wikipedia.org/wiki/Hamming_distance
|
||||
*/
|
||||
public class HammingDistance {
|
||||
public final class HammingDistance {
|
||||
private HammingDistance() {
|
||||
}
|
||||
|
||||
/**
|
||||
* calculate the hamming distance between two strings of equal length
|
||||
|
@ -44,7 +44,9 @@ import java.util.HashMap;
|
||||
* recommend checking out the wikipedia page and professor Anany Levitin's book:
|
||||
* Introduction To The Design And Analysis Of Algorithms.
|
||||
*/
|
||||
public class HorspoolSearch {
|
||||
public final class HorspoolSearch {
|
||||
private HorspoolSearch() {
|
||||
}
|
||||
|
||||
private static HashMap<Character, Integer> shiftValues; // bad symbol table
|
||||
private static Integer patternLength;
|
||||
|
@ -5,7 +5,9 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class Isomorphic {
|
||||
public final class Isomorphic {
|
||||
private Isomorphic() {
|
||||
}
|
||||
|
||||
public static boolean checkStrings(String s, String t) {
|
||||
if (s.length() != t.length()) {
|
||||
|
@ -4,7 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class LetterCombinationsOfPhoneNumber {
|
||||
public final class LetterCombinationsOfPhoneNumber {
|
||||
private LetterCombinationsOfPhoneNumber() {
|
||||
}
|
||||
|
||||
static Character[][] numberToCharMap;
|
||||
|
||||
|
@ -3,7 +3,9 @@ package com.thealgorithms.strings;
|
||||
// Longest Palindromic Substring
|
||||
import java.util.Scanner;
|
||||
|
||||
class LongestPalindromicSubstring {
|
||||
final class LongestPalindromicSubstring {
|
||||
private LongestPalindromicSubstring() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Solution s = new Solution();
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
public class Lower {
|
||||
public final class Lower {
|
||||
private Lower() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Driver Code
|
||||
|
@ -3,7 +3,9 @@
|
||||
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
public class MyAtoi {
|
||||
public final class MyAtoi {
|
||||
private MyAtoi() {
|
||||
}
|
||||
public static int myAtoi(String s) {
|
||||
s = s.trim();
|
||||
char[] char_1 = s.toCharArray();
|
||||
|
@ -3,7 +3,9 @@ package com.thealgorithms.strings;
|
||||
/**
|
||||
* Wikipedia: https://en.wikipedia.org/wiki/Palindrome
|
||||
*/
|
||||
class Palindrome {
|
||||
final class Palindrome {
|
||||
private Palindrome() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is palindrome string or not using String Builder
|
||||
|
@ -5,7 +5,9 @@ import java.util.HashSet;
|
||||
/**
|
||||
* Wikipedia: https://en.wikipedia.org/wiki/Pangram
|
||||
*/
|
||||
public class Pangram {
|
||||
public final class Pangram {
|
||||
private Pangram() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test code
|
||||
|
@ -11,7 +11,9 @@ Backtracking algorithm used in the program:-
|
||||
again, and we backtrack to the previous position and swap B with C. So, now we got ABC and ACB.
|
||||
>>Repeat these steps for BAC and CBA, to get all the permutations.
|
||||
*/
|
||||
public class PermuteString {
|
||||
public final class PermuteString {
|
||||
private PermuteString() {
|
||||
}
|
||||
|
||||
// Function for swapping the characters at position I with character at position j
|
||||
public static String swapString(String a, int i, int j) {
|
||||
|
@ -3,7 +3,9 @@ package com.thealgorithms.strings;
|
||||
/**
|
||||
* Reverse String using different version
|
||||
*/
|
||||
public class ReverseString {
|
||||
public final class ReverseString {
|
||||
private ReverseString() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
assert reverse("abc123").equals("321cba");
|
||||
|
@ -4,7 +4,9 @@ package com.thealgorithms.strings;
|
||||
* Reverse String using Recursion
|
||||
*/
|
||||
|
||||
public class ReverseStringRecursive {
|
||||
public final class ReverseStringRecursive {
|
||||
private ReverseStringRecursive() {
|
||||
}
|
||||
/**
|
||||
* @param str string to be reversed
|
||||
* @return reversed string
|
||||
|
@ -6,7 +6,9 @@ package com.thealgorithms.strings;
|
||||
* the string "abcdef" to the end of the string, so that the original string
|
||||
* becomes the string "cdefab"
|
||||
*/
|
||||
public class Rotation {
|
||||
public final class Rotation {
|
||||
private Rotation() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
assert rotation("abcdef", 2).equals("cdefab");
|
||||
|
@ -4,7 +4,9 @@ package com.thealgorithms.strings;
|
||||
* string
|
||||
* @author Swarga-codes (https://github.com/Swarga-codes)
|
||||
*/
|
||||
public class StringCompression {
|
||||
public final class StringCompression {
|
||||
private StringCompression() {
|
||||
}
|
||||
/**
|
||||
* Returns the compressed or encoded string
|
||||
*
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
public class Upper {
|
||||
public final class Upper {
|
||||
private Upper() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Driver Code
|
||||
|
@ -4,7 +4,9 @@ package com.thealgorithms.strings;
|
||||
// the same type of brackets. Open brackets must be closed in the correct order. Every close
|
||||
// bracket has a corresponding open bracket of the same type.
|
||||
|
||||
public class ValidParentheses {
|
||||
public final class ValidParentheses {
|
||||
private ValidParentheses() {
|
||||
}
|
||||
public static boolean isValid(String s) {
|
||||
char[] stack = new char[s.length()];
|
||||
int head = 0;
|
||||
|
@ -38,7 +38,9 @@ import java.util.Queue;
|
||||
All the words in wordList are unique.
|
||||
*/
|
||||
|
||||
class WordLadder {
|
||||
final class WordLadder {
|
||||
private WordLadder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This function finds the ladderLength
|
||||
|
@ -2,7 +2,9 @@ package com.thealgorithms.strings;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
class longestNonRepeativeSubstring {
|
||||
final class longestNonRepeativeSubstring {
|
||||
private longestNonRepeativeSubstring() {
|
||||
}
|
||||
|
||||
public static int lengthOfLongestSubstring(String s) {
|
||||
int max = 0, start = 0, i = 0;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.thealgorithms.strings.zigZagPattern;
|
||||
|
||||
class zigZagPattern {
|
||||
final class zigZagPattern {
|
||||
private zigZagPattern() {
|
||||
}
|
||||
|
||||
public static String encode(String s, int numRows) {
|
||||
if (numRows < 2 || s.length() < numRows) return s;
|
||||
|
Reference in New Issue
Block a user