Best approach for beginners using Java
IntuitionThis problem involves selecting rewards for two mice in a way that maximizes the total reward. The first mouse gets to pick k rewards from reward1, whi
# Intuition
This problem involves selecting rewards for two mice in a way that maximizes the total reward. The first mouse gets to pick `k` rewards from `reward1`, while the second mouse gets the remaining rewards from `reward2`. Since `reward2` is chosen by default, we need to decide which `k` rewards should be swapped from `reward2` to `reward1` to maximize the total.

# Approach
1. Compute the initial total by summing all values from `reward2` (assuming all rewards are given to the second mouse).
2. Compute the difference array `arr[i] = reward1[i] - reward2[i]`, which tells us how much more we gain by giving the reward to the first mouse instead of the second.
3. Sort `arr` in ascending order.
4. Pick the `k` largest values from `arr` and add them to `total`, as they represent the highest gains from switching.
5. Return the final computed `total`.

# Complexity
- Time complexity: $$O(n \log n)$$ 
- Space complexity: $$O(n)$$ for storing the difference array.

# Code
```java []
class Solution {
    public int miceAndCheese(int[] reward1, int[] reward2, int k) {
        int total = 0;
        for (int num : reward2) {
            total += num;
        }

        int arr[] = new int[reward1.length];

        for (int i = 0; i < reward1.length; i++) {
            arr[i] = reward1[i] - reward2[i];
        }
        Arrays.sort(arr);
        for (int i = 0; i < k; i++) {
            total += arr[reward1.length - 1 - i];
        }
        return total;
    }
}
```
['Java']