Medium · Math

Maximum Split of Positive Even Integers

Given an integer finalSum in [0, 10¹⁰], split it into the largest possible number of distinct positive even integers that add up to finalSum and return them in any order, or return an empty list if no such split exists.

Examples

Example 1

finalSum = 12

Output: [2,4,6]

Example 2

finalSum = 7 (odd)

Output: [] (odd)

Rebuild it in the studio

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Math problems