-
Notifications
You must be signed in to change notification settings - Fork 123
Fixing A_SumOfNumbers test case #5
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
Conversation
@@ -40,7 +40,7 @@ public static <T> List<T> getUniqueNumberFromList(List<T> input) { | |||
return input.stream().distinct().toList(); | |||
} | |||
|
|||
public static long sumOfNumbers(List<Integer> input) { | |||
public static Integer sumOfNumbers(List<Integer> input) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sum of the list of integers should be stored in a long
or a data type with sufficient capacity to avoid potential overflow. Using an int
might lead to incorrect results for larger lists.
@@ -8,8 +8,8 @@ | |||
|
|||
/* | |||
* Given an array of {5,6,7,8,5,5,8,8,7) | |||
* Find the sum of the unique elements. | |||
* The output should be in this case is: 26. | |||
* Find the sum of the all the elements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation update is clear and looks good.
@@ -16,10 +16,10 @@ class I_SegregateEvenOddNumbers { | |||
@Test | |||
@Disabled | |||
void testSegregationOfEvenOddNumbersTest() { | |||
final var input = IntStream.range(1, 50).boxed(); | |||
final var mySolution = NumbersProblemSolution.segregateEvenOddNumbers(input); | |||
final var input = IntStream.range(1, 50).boxed().toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a terminal operation here appears unnecessary and might result in slowing down of unit test case performance. We can streamline this code by keeping it within the Stream API.
Closing this MR as the documentation has been updated. Thanks for your contribution! |
No description provided.