Find ALL the paths in a binary tree equal to a sum


  • 0
    S

    This question was asked for an SDE 2 position.

    For example, given the following binary tree:

    [2,3,5,4,8,6,-2,null,null,null,null,null,null,null,2] and sum = 7

                                2
                              /     \
                            3         5
                         /     \    /   \
                        4       8  6     -2
                                          \
                                           2
    

    Print : [3,4] , [2,5] , [2,5,-2,2]


Log in to reply