EASY JAVA
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int minimumEffort(int[][] tasks) {
        HashMap<Integer, Integer> a = new HashMap<>();
        for (int i = 0; i < tasks.length; i++) {
            a.put(i, tasks[i][1] - tasks[i][0]);
        }
        List<Integer> ind = new ArrayList<>(a.keySet());
        Collections.sort(ind, (i, j) -> a.get(j) - a.get(i));
        int energy = 0, curr = 0;
        for (int i = 0; i < ind.size(); i++) {
            int z = ind.get(i);
            int actual = tasks[z][0], minimum = tasks[z][1];
            if (curr < minimum) {
                energy += (minimum - curr);
                curr = minimum;
            }
            curr -= actual;
        }
        return energy;
    }
}

```
['Java']