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 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 cube_root == sum_of_digits;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,11 +44,7 @@ public class LinkListSort {
|
|||||||
Arrays.sort(b);
|
Arrays.sort(b);
|
||||||
// array b is sorted and it will return true when checked with sorted list
|
// array b is sorted and it will return true when checked with sorted list
|
||||||
LinkListSort uu = new LinkListSort();
|
LinkListSort uu = new LinkListSort();
|
||||||
if (uu.compare(a, b)) {
|
return uu.compare(a, b);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// The given array and the expected array is checked if both are same then true
|
// The given array and the expected array is checked if both are same then true
|
||||||
// is displayed else false is displayed
|
// is displayed else false is displayed
|
||||||
case 2:
|
case 2:
|
||||||
@ -73,11 +69,7 @@ public class LinkListSort {
|
|||||||
}
|
}
|
||||||
LinkListSort uu1 = new LinkListSort();
|
LinkListSort uu1 = new LinkListSort();
|
||||||
// array b is not sorted and it will return false when checked with sorted list
|
// array b is not sorted and it will return false when checked with sorted list
|
||||||
if (uu1.compare(a, b)) {
|
return uu1.compare(a, b);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// The given array and the expected array is checked if both are same then true
|
// The given array and the expected array is checked if both are same then true
|
||||||
// is displayed else false is displayed
|
// is displayed else false is displayed
|
||||||
case 3:
|
case 3:
|
||||||
@ -103,11 +95,7 @@ public class LinkListSort {
|
|||||||
Arrays.sort(b);
|
Arrays.sort(b);
|
||||||
// array b is sorted and it will return true when checked with sorted list
|
// array b is sorted and it will return true when checked with sorted list
|
||||||
LinkListSort uu2 = new LinkListSort();
|
LinkListSort uu2 = new LinkListSort();
|
||||||
if (uu2.compare(a, b)) {
|
return uu2.compare(a, b);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// The given array and the expected array is checked if both are same then true
|
// The given array and the expected array is checked if both are same then true
|
||||||
// is displayed else false is displayed
|
// is displayed else false is displayed
|
||||||
default:
|
default:
|
||||||
|
@ -56,11 +56,8 @@ public class Anagrams {
|
|||||||
Arrays.sort(
|
Arrays.sort(
|
||||||
d
|
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 */
|
);/* 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;
|
return Arrays.equals(c, d);
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user