Maximum Alternating Sum of Squares

Solution Code

Time Complexity

O(n log n)

Space Complexity

O(n)