We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I think its best explained as a bunch of blocks being stacked upon eachother, sometimes a block will be heavier than others, othertimes it wont stack on another block. By caching WHERE the blocks start and end and how high they are at that point, you can find the maximum value of the graph. This doesn't mean you'd know exactly where the maximum is, making it a much simpler problem that can be solved O(n * rows)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
I think its best explained as a bunch of blocks being stacked upon eachother, sometimes a block will be heavier than others, othertimes it wont stack on another block. By caching WHERE the blocks start and end and how high they are at that point, you can find the maximum value of the graph. This doesn't mean you'd know exactly where the maximum is, making it a much simpler problem that can be solved O(n * rows)