3727. Maximum Alternating Sum of Squares

Share this post on:
class Solution:
    def maxAlternatingSum(self, nums: List[int]) -> int:
        nums = sorted([abs(n) for n in nums])
        return sum([n * n for n in nums[len(nums)//2:]]) - sum([n * n for n in nums[:len(nums)//2]])

I hope every VO/OA is as simple as this one

Share this post on:

Leave a Reply

Your email address will not be published. Required fields are marked *