Level: Medium Concepts: Greedy,Dynamic programming, hashing Problem link: http://www.codechef.com/CRNM2014/problems/CRANBROM This one can be done in many ways. Here is an O(n) solution . Below I will outline a way where we dynamically store whatever best so far we could have earned every time we find a broom. Whenever we have a customer we will compare the current profit with the one will be making if we sell the broom being demanded. Pseudocode:
This question is marked "community wiki".
asked 11 Feb '14, 04:07
