Skip to content

Practice Mice and Cheese

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2611
LeetCode Problem

Mice and Cheese

Problem Statement

Assign each cheese type to exactly one mouse. Type i awards reward1[i] when the first mouse eats it and reward2[i] when the second eats it. The first mouse must eat exactly k types. Return the largest total reward.

Source: Mice and Cheese on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
reward1 = [1,1,3,4], reward2 = [4,4,1,1], k = 2
Output
15

# Example 2

Input
reward1 = [1,1], reward2 = [1,1], k = 2
Output
2

Constraints

1 <= n == reward1.length == reward2.length <= 10^5
1 <= reward1[i], reward2[i] <= 1000
0 <= k <= n

Related LeetCode Problems

Practice more problems similar to Mice and Cheese.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.