Codility AbsDistinct solution

Опубликовано: 16 Октябрь 2024
на канале: Dave Kirkwood
1,169
17

AbsDistinct is the first exercise in the Caterpillar method lesson on Codility. The aim is to count the number of distinct absolute values in an array.

Here is my straightforward Java solution. I don't use the caterpillar method, I simply scan through the array and use a HashSet to keep a track of the values that I've already seen.

The solution scores 100% on Codility.