Skip to content

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

Closed
wants to merge 6 commits into from
Closed

Conversation

Praj-11
Copy link

@Praj-11 Praj-11 commented Apr 6, 2025

No description provided.

@@ -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) {
Copy link
Owner

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.
Copy link
Owner

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();
Copy link
Owner

@ZahidFKhan ZahidFKhan Apr 6, 2025

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.

@ZahidFKhan
Copy link
Owner

Closing this MR as the documentation has been updated.

Thanks for your contribution!
Future pull requests are always welcome.

@ZahidFKhan ZahidFKhan closed this Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants