Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
You are using
index
method to find the first occurrence ofactual
, but there may be duplicate values in each row.OP solved it, closing
Apparently not. You must traverse all grids whether starting from bottom or at the top to identify the maximum path down the pyramid. The T.C can be
O(N^2)
ifN
is the length of the bottom row of the pyramid or justO(N)
wherebyN
is the number of cells in the pyramid.OP solved it, closing
Neither. The number of path to reach each cell of the pyramid can be represented by the pascal triangle. As for how to derive those numbers, a simple visualization with a pen and paper should suffice! ^^
'down' can be misleading.
I found it misleading. doesnt mean everyone will find it misleading.
Sorry for the confusion. Should have clarifed that only some people would be confused by it.
Recursion has a T.C of
O(2^N)
which is too slow here. However, you had already found the recurrene relation with recursion, so you can simplify the code to a top-down / bottom-up iterative approach, which will cost at most O(N) time wherebyN
is the total sum of each row's lengthdown
is not misleading. It can go down to the next row's left (if it has one) or right (if it has one) or both (if it is in the bounds of the pyramid) The visualization is clear regarding this aspect, as for the latter wording, it has been raised belowResolved
Yeah, output is (23, 23) now. I thought the tests are isolated. Ok, I'll take care about it. Thank you!
It's not a problem in the tests, try calling your function locally like in the tests, that is, one after the other:
And see what you get.
"The problem is, memo isn't reset, it keeps its value"
Is it the solution problem? Then don't understand why.
Or tests problem?
"Have you tried locally calling your function more than once?"
Sure, many times, with the same or different pyramids, but one per try.
"...distinguish between '11' + '10' and '111' + '0'?"
Didn't think about it. Looks reasonable. The test suite is pretty small, probably need to make it bigger
Have you tried locally calling your function more than once? The problem is, memo isn't reset, it keeps its value. Also
point
being a concatenation of x + y, how would you distinguish between '11' + '10' and '111' + '0'?Loading more items...