mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-24 09:20:53 +07:00
25 lines
585 B
Java
25 lines
585 B
Java
// "Replace Stream API chain with loop" "true-preview"
|
|
|
|
import java.util.*;
|
|
|
|
public class Main {
|
|
private static long test(List<?> list) {
|
|
long count = 0L;
|
|
Set<Object> uniqueValues = new HashSet<>();
|
|
long toSkip = list.size() / 2;
|
|
for (Object o : list) {
|
|
if (toSkip > 0) {
|
|
toSkip--;
|
|
continue;
|
|
}
|
|
if (uniqueValues.add(o)) {
|
|
count++;
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
System.out.println(test(Arrays.asList(1,2,3,3,2,1,1,2,3)));
|
|
}
|
|
} |