2
public List<Long> maximumEvenSplit(long finalSum) {3
List<Long> res = new ArrayList<Long>();4
// odd sum cannot be divided into even numbers5
if (finalSum % 2 != 0) {8
// Greedy approach, try to build the total sum using minimum unique even nos10
long remainingSum = finalSum;11
// as long as we can add subtract this number from remaining sum12
while (currNum <= remainingSum) {14
remainingSum -= currNum; // reducing remaining sum15
currNum += 2; // next even number17
// now, remaining sum cannot be fulfilled by any larger even number18
// so extract the largest even number we added to the last index of res, and make it even larger19
// by adding this current remaining sum20
// add remaining sum to the last element21
long last = res.remove(res.size() - 1);22
res.add(last + remainingSum);