Python | Sorting
Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \nO(nlogn): where n is the size of the array. nlogn is due to sorting the array.\n\n- 
# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(nlogn)$$: where n is the size of the array. `nlogn` is due to sorting the array.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$: because store the data in a seperate list\n\n# Code\n```\nimport array\n\nclass Solution:\n    def miceAndCheese(self, reward1: List[int], reward2: List[int], k: int) -> int:\n        arr = []\n        n = len(reward1)\n\n        for idx in range(n):\n            arr.append(\n                array.array(\'i\', [\n                    reward1[idx] - reward2[idx], reward1[idx], reward2[idx]\n                ])\n            )\n        \n        arr.sort(key=lambda x: x[0], reverse=True)\n        max_profit = 0\n        idx = 0\n        while k > 0:\n            k -= 1\n            max_profit += arr[idx][1]\n            idx += 1\n\n        while idx < n:\n            max_profit += arr[idx][2]\n            idx += 1\n\n        return max_profit\n```
['Python3']