Simplifying boolean returns (#3796)
* Simplifying boolean returns * add comment back
This commit is contained in:
parent
fb09eb289e
commit
c6694fc1bd
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user