Count Distinct Element Leetcode Java