Leetcode 2279 Solution

This article provides solution to leetcode question 2279 (maximum-split-of-positive-even-integers)

https://leetcode.com/problems/maximum-split-of-positive-even-integers

Solution

class Solution: def maximumEvenSplit(self, finalSum: int) -> List[int]: if finalSum % 2 == 1: return []
curr = 2 ans = [] while 2 * curr < finalSum and finalSum > 0: ans.append(curr) finalSum -= curr curr += 2
ans.append(finalSum) return ans