-
Notifications
You must be signed in to change notification settings - Fork 127
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
Changes from all commits
6d910ba
974acc0
7323322
1fa5f4d
88fe10b
1735e97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. The documentation update is clear and looks good. |
||
* The output should be in this case is: 59. | ||
*/ | ||
class A_SumOfNumbers { | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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. |
||
final var mySolution = NumbersProblemSolution.segregateEvenOddNumbers(input.stream()); | ||
final var yourSolution = new ArrayList<>(); | ||
|
||
Assertions.assertEquals(mySolution, yourSolution); | ||
} | ||
} |
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 anint
might lead to incorrect results for larger lists.