We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f4de1c9 commit 5eb5f56Copy full SHA for 5eb5f56
src/test/java/com/github/streams/practice/c_hard/numbers/HardNumbersProblemSolution.java
@@ -23,10 +23,11 @@ public static List<Integer> generateIntStreamOfPrimeNumberStream(final int limit
23
.toList();
24
}
25
26
- public static Integer largestConsecutiveSequence(List<Integer> input) {
+ public static Integer largestConsecutiveSequence(final List<Integer> input) {
27
final var set = new HashSet<>(input);
28
- return set.stream()
29
- .filter(value -> set.contains(value - 1))
+ return input.stream()
+ .distinct()
30
+ .filter(value -> !set.contains(value - 1))
31
.collect(
32
Collectors.toMap(
33
Function.identity(),
0 commit comments