Maximum Split of Positive Even Integers

You are given an integer finalSum. Split it into a sum of a maximum number of unique positive even integers.

Return a list of integers that represent a valid split containing a maximum number of integers. If no valid split exists for finalSum, return an empty list. You may return the integers in any order.

Example 1
InputfinalSum = 12
Output[2,4,6]
The split (2 + 4 + 6) has the maximum number of integers, which is 3, so [2,4,6] is returned.
Example 2
InputfinalSum = 7
Output[]
There are no valid splits for the given finalSum, so an empty array is returned.

Constraints

  • 1 <= finalSum <= 10^10

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate