Minimum Initial Energy to Finish Tasks

Solution Code

Time Complexity

O(n log n)

Space Complexity

O(log n)