Interview Question
- 1of 1 vote
AnswerGiven k,n,m. where k is no. of coconuts you initially have. n is some no. such that if you have >=n coconuts, you become stressed otherwise you are normal. m is the no. of shops.You go from 1st shop to m-th shop without skipping any shop. At i-th shop, either you buy Si coconuts or sell Si coconuts. If you are stressed then you must become normal at next shop. If you have less than Si coconuts and you want to sell then you must sell all the coconuts you have. The task is to calculate maximum possible changes of your mood from stressed to normal or vice-versa.
- po55ible August 16, 2015 in United States| Report Duplicate | Flag | PURGE
dp , matrix ,recursion , flipkart
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
"At i-th shop, either you buy Si coconuts or sell Si coconuts"
- asen October 13, 2015"If you are stressed then you must become normal at next shop"
what if cur_coconuts - S[i] is still >= n ? How do I update mood in this case ? Do we have to deliberately make cur_coconuts = n-1 so that we must become normal at next shop ? But this violates that he either sells or buys Si coconut at ith shop.