diff --git a/src/main/java/com/thealgorithms/maths/DudeneyNumber.java b/src/main/java/com/thealgorithms/maths/DudeneyNumber.java index 11fe03d8..ab9fb70b 100644 --- a/src/main/java/com/thealgorithms/maths/DudeneyNumber.java +++ b/src/main/java/com/thealgorithms/maths/DudeneyNumber.java @@ -33,10 +33,6 @@ public class DudeneyNumber { } //If the cube root of the number is not equal to the sum of its digits we return false. - if (cube_root != sum_of_digits) { - return false; - } - - return true; + return cube_root == sum_of_digits; } } diff --git a/src/main/java/com/thealgorithms/sorts/LinkListSort.java b/src/main/java/com/thealgorithms/sorts/LinkListSort.java index ed0e1db1..3c9ba1b7 100644 --- a/src/main/java/com/thealgorithms/sorts/LinkListSort.java +++ b/src/main/java/com/thealgorithms/sorts/LinkListSort.java @@ -44,11 +44,7 @@ public class LinkListSort { Arrays.sort(b); // array b is sorted and it will return true when checked with sorted list LinkListSort uu = new LinkListSort(); - if (uu.compare(a, b)) { - return true; - } else { - return false; - } + return uu.compare(a, b); // The given array and the expected array is checked if both are same then true // is displayed else false is displayed case 2: @@ -73,11 +69,7 @@ public class LinkListSort { } LinkListSort uu1 = new LinkListSort(); // array b is not sorted and it will return false when checked with sorted list - if (uu1.compare(a, b)) { - return true; - } else { - return false; - } + return uu1.compare(a, b); // The given array and the expected array is checked if both are same then true // is displayed else false is displayed case 3: @@ -103,11 +95,7 @@ public class LinkListSort { Arrays.sort(b); // array b is sorted and it will return true when checked with sorted list LinkListSort uu2 = new LinkListSort(); - if (uu2.compare(a, b)) { - return true; - } else { - return false; - } + return uu2.compare(a, b); // The given array and the expected array is checked if both are same then true // is displayed else false is displayed default: diff --git a/src/main/java/com/thealgorithms/strings/Anagrams.java b/src/main/java/com/thealgorithms/strings/Anagrams.java index 1d61e42e..dcde8647 100644 --- a/src/main/java/com/thealgorithms/strings/Anagrams.java +++ b/src/main/java/com/thealgorithms/strings/Anagrams.java @@ -56,11 +56,8 @@ public class Anagrams { Arrays.sort( d );/* In this approach the strings are stored in the character arrays and both the arrays are sorted. After that both the arrays are compared for checking anangram */ - if (Arrays.equals(c, d)) { - return true; - } else { - return false; - } + + return Arrays.equals(c, d); } }