Count Distinct Element Leetcode Problems Javascript