Count Distinct Element Leetcode Python