Maximum Distinct Elements Leetcode Javascript Practice