You are viewing a single comment's thread. Return to all comments →
Recursive problem statement which helped me to understand problem:
cost(B:array) = { len of B is 2 => we take or not take the last element max(abs(B[0] - B[1]), B[0]) len of B > 2 => Take first from B -> B[0] calculate case if next element is taken |B[0] - B[1]| + cost(rest of B) calculcate case if next element is not taken B[0] + cost(take rest of B but replace first with 0) return maximum of these 2 }
Coming from this it is easier to develop iterative approach
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Cost
You are viewing a single comment's thread. Return to all comments →
Recursive problem statement which helped me to understand problem:
Coming from this it is easier to develop iterative approach