Skip to content

Chore/cleanup #6290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package com.thealgorithms.dynamicprogramming;

import java.util.Arrays;

/**
* Author: Siddhant Swarup Mallick
* Github: https://github.com/siddhant2002
Expand All @@ -12,11 +16,6 @@
* This program calculates the number of unique paths possible for a robot to reach the bottom-right corner
* of an m x n grid using dynamic programming.
*/

package com.thealgorithms.dynamicprogramming;

import java.util.Arrays;

public final class UniquePaths {

private UniquePaths() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package com.thealgorithms.dynamicprogramming;

/**
*
* Author: Janmesh Singh
Expand All @@ -11,9 +13,6 @@
* Use DP to return True if the pattern matches the entire text and False otherwise
*
*/

package com.thealgorithms.dynamicprogramming;

public final class WildcardMatching {
private WildcardMatching() {
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/thealgorithms/maths/DudeneyNumber.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.thealgorithms.maths;

/**
* A number is said to be Dudeney if the sum of the digits, is the cube root of the entered number.
* Example- Let the number be 512, its sum of digits is 5+1+2=8. The cube root of 512 is also 8.
* Since, the sum of the digits is equal to the cube root of the entered number;
* it is a Dudeney Number.
*/
package com.thealgorithms.maths;

public final class DudeneyNumber {
private DudeneyNumber() {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* @author Md Asif Joardar
*/

package com.thealgorithms.scheduling;

import com.thealgorithms.devutils.entities.ProcessDetails;
Expand All @@ -11,6 +7,7 @@
import java.util.Queue;

/**
* @author Md Asif Joardar
* The Round-robin scheduling algorithm is a kind of preemptive First come, First Serve CPU
* Scheduling algorithm. This can be understood here -
* https://www.scaler.com/topics/round-robin-scheduling-in-os/
Expand Down
35 changes: 22 additions & 13 deletions src/main/java/com/thealgorithms/strings/Anagrams.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ private Anagrams() {
* @param t the second string
* @return true if the strings are anagrams, false otherwise
*/
public static boolean approach1(String s, String t) {
public static boolean areAnagramsBySorting(String s, String t) {
s = s.toLowerCase().replaceAll("[^a-z]", "");
t = t.toLowerCase().replaceAll("[^a-z]", "");
if (s.length() != t.length()) {
return false;
}
Expand All @@ -43,17 +45,18 @@ public static boolean approach1(String s, String t) {
* @param t the second string
* @return true if the strings are anagrams, false otherwise
*/
public static boolean approach2(String s, String t) {
if (s.length() != t.length()) {
return false;
public static boolean areAnagramsByCountingChars(String s, String t) {
s = s.toLowerCase().replaceAll("[^a-z]", "");
t = t.toLowerCase().replaceAll("[^a-z]", "");
int[] dict = new int[128];
for (char ch : s.toCharArray()) {
dict[ch]++;
}
int[] charCount = new int[26];
for (int i = 0; i < s.length(); i++) {
charCount[s.charAt(i) - 'a']++;
charCount[t.charAt(i) - 'a']--;
for (char ch : t.toCharArray()) {
dict[ch]--;
}
for (int count : charCount) {
if (count != 0) {
for (int e : dict) {
if (e != 0) {
return false;
}
}
Expand All @@ -70,7 +73,9 @@ public static boolean approach2(String s, String t) {
* @param t the second string
* @return true if the strings are anagrams, false otherwise
*/
public static boolean approach3(String s, String t) {
public static boolean areAnagramsByCountingCharsSingleArray(String s, String t) {
s = s.toLowerCase().replaceAll("[^a-z]", "");
t = t.toLowerCase().replaceAll("[^a-z]", "");
if (s.length() != t.length()) {
return false;
}
Expand All @@ -96,7 +101,9 @@ public static boolean approach3(String s, String t) {
* @param t the second string
* @return true if the strings are anagrams, false otherwise
*/
public static boolean approach4(String s, String t) {
public static boolean areAnagramsUsingHashMap(String s, String t) {
s = s.toLowerCase().replaceAll("[^a-z]", "");
t = t.toLowerCase().replaceAll("[^a-z]", "");
if (s.length() != t.length()) {
return false;
}
Expand All @@ -123,7 +130,9 @@ public static boolean approach4(String s, String t) {
* @param t the second string
* @return true if the strings are anagrams, false otherwise
*/
public static boolean approach5(String s, String t) {
public static boolean areAnagramsBySingleFreqArray(String s, String t) {
s = s.toLowerCase().replaceAll("[^a-z]", "");
t = t.toLowerCase().replaceAll("[^a-z]", "");
if (s.length() != t.length()) {
return false;
}
Expand Down
110 changes: 0 additions & 110 deletions src/main/java/com/thealgorithms/strings/CheckAnagrams.java

This file was deleted.

13 changes: 7 additions & 6 deletions src/test/java/com/thealgorithms/strings/AnagramsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,37 @@ record AnagramTestCase(String input1, String input2, boolean expected) {

private static Stream<AnagramTestCase> anagramTestData() {
return Stream.of(new AnagramTestCase("late", "tale", true), new AnagramTestCase("late", "teal", true), new AnagramTestCase("listen", "silent", true), new AnagramTestCase("hello", "olelh", true), new AnagramTestCase("hello", "world", false), new AnagramTestCase("deal", "lead", true),
new AnagramTestCase("binary", "brainy", true), new AnagramTestCase("adobe", "abode", true), new AnagramTestCase("cat", "act", true), new AnagramTestCase("cat", "cut", false));
new AnagramTestCase("binary", "brainy", true), new AnagramTestCase("adobe", "abode", true), new AnagramTestCase("cat", "act", true), new AnagramTestCase("cat", "cut", false), new AnagramTestCase("Listen", "Silent", true), new AnagramTestCase("Dormitory", "DirtyRoom", true),
new AnagramTestCase("Schoolmaster", "TheClassroom", true), new AnagramTestCase("Astronomer", "MoonStarer", true), new AnagramTestCase("Conversation", "VoicesRantOn", true));
}

@ParameterizedTest
@MethodSource("anagramTestData")
void testApproach1(AnagramTestCase testCase) {
assertEquals(testCase.expected(), Anagrams.approach1(testCase.input1(), testCase.input2()));
assertEquals(testCase.expected(), Anagrams.areAnagramsBySorting(testCase.input1(), testCase.input2()));
}

@ParameterizedTest
@MethodSource("anagramTestData")
void testApproach2(AnagramTestCase testCase) {
assertEquals(testCase.expected(), Anagrams.approach2(testCase.input1(), testCase.input2()));
assertEquals(testCase.expected(), Anagrams.areAnagramsByCountingChars(testCase.input1(), testCase.input2()));
}

@ParameterizedTest
@MethodSource("anagramTestData")
void testApproach3(AnagramTestCase testCase) {
assertEquals(testCase.expected(), Anagrams.approach3(testCase.input1(), testCase.input2()));
assertEquals(testCase.expected(), Anagrams.areAnagramsByCountingCharsSingleArray(testCase.input1(), testCase.input2()));
}

@ParameterizedTest
@MethodSource("anagramTestData")
void testApproach4(AnagramTestCase testCase) {
assertEquals(testCase.expected(), Anagrams.approach4(testCase.input1(), testCase.input2()));
assertEquals(testCase.expected(), Anagrams.areAnagramsUsingHashMap(testCase.input1(), testCase.input2()));
}

@ParameterizedTest
@MethodSource("anagramTestData")
void testApproach5(AnagramTestCase testCase) {
assertEquals(testCase.expected(), Anagrams.approach5(testCase.input1(), testCase.input2()));
assertEquals(testCase.expected(), Anagrams.areAnagramsBySingleFreqArray(testCase.input1(), testCase.input2()));
}
}
69 changes: 0 additions & 69 deletions src/test/java/com/thealgorithms/strings/CheckAnagramsTest.java

This file was deleted.