Constraints are small so we can do it with the most obvious way. First of all, add the first two numbers, now we need to check how many sodas we can buy, and after that, when we buy them how many empty total bottles we are having left after buying and drinking the current sodas. Do this until we are unable to buy any more. Also check the case of infinite , there are 2 cases, either soda costs 0, or soda costs 1 but we have at least 1 bottle.
No comments:
Post a Comment