Java | Priority Queue | Clean code | O (n log k) 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 
# 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: $$O(n * log(k))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(k)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n  public int miceAndCheese(int[] reward1, int[] reward2, int k) {\n    var ans = 0;\n    var n = reward1.length;\n    var queue = new PriorityQueue<int[]>((a, b) -> Integer.compare(a[0], b[0]));\n    \n    for (var i=0; i<n; i++) {\n      queue.offer(new int[] {reward1[i] - reward2[i], i});\n      \n      if (queue.size() > k)\n        queue.poll();\n    }\n    while (!queue.isEmpty()) {\n      var a = queue.poll();\n      ans += reward1[a[1]];\n      reward2[a[1]] = 0;\n    }\n    for (var a : reward2)\n      ans += a;\n    \n    return ans;\n  }\n}\n```\nIf you like my solution, pleae upvote it!
['Heap (Priority Queue)', 'Java']