I\'ve got a numeric pyramid like this
7 4 8 1 8 9 2 4 6 7 4 6 7 4 9 4 9 7 3 8 8 routes: 32
every number indexed by
Simplest way is to go bottom up and you have O(N) compexity. This case you do not need dynamic programming or recursion. Just compose another tree where number at higher level is max of numbers of lower layer.