I was too young and did not pass the interview because I did not give them an O(n) algorithm.
Code\n\nclass Solution {\npublic:\n  int miceAndCheese(vector<int>& reward1, vector<int>& reward2, int k) {\n    transform(reward1.begin(), reward1.end(), rewar
# Code\n```\nclass Solution {\npublic:\n  int miceAndCheese(vector<int>& reward1, vector<int>& reward2, int k) {\n    transform(reward1.begin(), reward1.end(), reward2.begin(), reward1.begin(), minus<int>());\n    nth_element(reward1.begin(), reward1.begin() + k, reward1.end(), greater<int>());\n    return accumulate(reward1.begin(), reward1.begin() + k, accumulate(reward2.begin(), reward2.end(), 0));\n  }\n};\n```
['C++']