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.
People who were able to solve only TestCase0 did not understand the question clearly.
Consider the triangle:
12106510505610
The correct path is 1->2->6->50 and the answer should be 1+2+6+50=59. If we use greedy, the path would be 1->10->10->10, and answer would be 31, which is smaller than 59. We should consider the largest possible sum out of all possible sum(satisfying the condition of moving to adjacent numbers only). Solving with dynamic programming is recommended. Question67 is the same problem with larger value of n.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #18: Maximum path sum I
You are viewing a single comment's thread. Return to all comments →
People who were able to solve only TestCase0 did not understand the question clearly. Consider the triangle:
The correct path is 1->2->6->50 and the answer should be 1+2+6+50=59. If we use greedy, the path would be 1->10->10->10, and answer would be 31, which is smaller than 59. We should consider the largest possible sum out of all possible sum(satisfying the condition of moving to adjacent numbers only). Solving with dynamic programming is recommended. Question67 is the same problem with larger value of n.