Your solution is unfortunately not correct. You do not reach the correct value and pass all tests.

I’m not sure exactly what your code is doing, but you should be able to use a bottom up, dynamic programming approach to reach the solution that only requires n(n+1)/2 additions.

Yeah sure, but can I go downward? it should be okay, because the first test is showing the result of adding the first number to the number on the same column

You can go downward, but the code will be much, much slower. Unfortunately, the combinatorics are working against you and debugging your top down attempt to traverse every single path is hard.

Yeah, I’m sure I’m missing something, because when I calculated a combination of adjacent numbers I got an even bigger number than the one the test is telling me I should return. My result of the calculation I did was the same as the result my code is giving, I’ll try to understand the problem more

It doesn’t, it checks the three numbers under the current one, and adds the biggest to the sum, and then either subtracts from the current index or adds to it, or leaves it as it is.

Ah. A greedy approach can miss the optimal path. The best path for the first 5 rows can then have the worst paths for the next 10 rows, roughly speaking.

Exactly, that’s why I’m so confused, because the sum I got was even bigger, I’m guessing by that I cannot go downwards, should I only check adjacent numbers? I’m so sorry man I know it’s stupid

In the form that the triangle is stored in, yeah, that’s an invalid direction. The 4 in the third row is not connected to the 8 in the fourth row, for example.