JS MinHeap Clean Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {number[][]} items\n * @param {number} k\n * @return {number}\n */\nvar findMaximumElegance = function (items, k) {\n    items.sort((a, b) => b[0] - a[0]);\n    let minHeap = new MinPriorityQueue();\n    let catSet = new Set();\n    let maxElegance = 0;\n    let totalProfit = 0;\n\n    for (let i = 0; i < items.length; i++) {\n        if (i >= k) {\n            if (catSet.has(items[i][1])) continue;\n            if (minHeap.isEmpty()) break;\n            totalProfit -= minHeap.dequeue().element;\n        }\n\n        if (catSet.has(items[i][1])) {\n            minHeap.enqueue(items[i][0]);\n        }\n        catSet.add(items[i][1]);\n        totalProfit += items[i][0];\n\n        if (i >= k - 1) {\n            maxElegance = Math.max(maxElegance, totalProfit + Math.pow(catSet.size, 2));\n        }\n    }\n\n    return maxElegance;\n};\n```
['JavaScript']