Codility Distinct Java solution

preview_player
Показать описание
Distinct is the first exercise in the sorting lesson on Codility. The objective is to count the number of distinct values in an array. This video shows my Java solution that scores 100% on Codility.
Рекомендации по теме
Комментарии
Автор

I'm new to this channel and it is so cool here for us aspiring software engineer hehe Keep it up, Sir!

brylle
Автор

My solution
import java.util.*;
class Solution {

public int solution(int[] A) {
// Implement your solution here
HashMap<Integer, Integer> fmap = new HashMap<>();
for(int i: A){
fmap.put(i, fmap.getOrDefault(i, 0)+1);
}
return fmap.size();
}
}

renukarule
join shbcf.ru