Easy Java Sorting | O(N logN) | Yogesh
Intuition
Fining maximum cheese by choosing best indices
Approach
Sort and go Greedy.
Complexity
Time complexity:

O(n logn)

Space complexity:

O(n)
Code
# Intuition
>Fining maximum cheese by choosing best indices

# Approach
>Sort and go Greedy.

# Complexity
- Time complexity:
>O(n logn)

- Space complexity:
>O(n)

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

        int[] differences = new int[reward1.length];
        for (int i = 0; i < reward1.length; i++) {
            differences[i] = reward1[i] - reward2[i];
        }

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