Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-170

Middle-Out Method

Problem

Apply middle-out reconciliation lite: an aggregate plus its siblings defines the total, so return aggregate + sum(siblings).

This total is then distributed down the hierarchy.

Hint

Middle-out starts at an intermediate level and works in both directions.

Test cases

case 1
in: [10,[1,2,3]]
expected: 16
case 2
in: [0,[]]
expected: 0
case 3
in: [5,[2]]
expected: 7
case 4
in: [1.5,[0.5,0.5]]
expected: 2.5
Starter codePython
def middle_out_method(aggregate, siblings):
    # Your code here
    pass

4 test cases · run your code against them in the editor