Count Distinct Element Leetcode Problems Javascript Array