2178. Maximum Split of Positive Even Integers

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2178

class Solution:
    def maximumEvenSplit(self, finalSum: int) -> List[int]:
        if finalSum % 2:
            return []
        i = 2
        res = []
        while i <= finalSum:
            res.append(i)
            finalSum -= i
            i += 2
        res[-1] += finalSum
        return res